This will parse your %PATH% environment variable and convert each directory to its shortname equivalent and then piece it all back together:
@echo off
SET MyPath=%PATH%
echo %MyPath%
echo --
setlocal EnableDelayedExpansion
SET TempPath="%MyPath:;=";"%"
SET var=
FOR %%a IN (%TempPath%) DO (
IF exist %%~sa (
SET "var=!var!;%%~sa"
) ELSE (
echo %%a does not exist
)
)
echo --
echo !var:~1!
Take the output and update the PATH variable in environment variables.
Related Contents:
- Adding a directory to the PATH environment variable in Windows
- ‘git’ is not recognized as an internal or external command
- How to set the PATH environment variable in Jenkins configuration on Windows?
- What is the difference between user variables and system variables?
- Error “‘git’ is not recognized as an internal or external command”
- Variables are not behaving as expected
- Example of delayed expansion in batch file
- Why does the 260 character path length limit exist in Windows?
- Is there a command to refresh environment variables from the command prompt in Windows?
- ‘Pretty print’ windows %PATH% variable – how to split on ‘;’ in CMD shell
- OpenSSL and error in reading openssl.conf file
- Setting a system environment variable from a Windows batch file?
- Access to build environment variables from a groovy script in a Jenkins build step (Windows)
- Where can I find my .emacs file for Emacs running on Windows?
- ‘chcp’ is not recognized as an internal or external command, operable program or batch file. on a Windows PC
- Where are environment variables stored in the Windows Registry?
- Set a persistent environment variable from cmd.exe
- List all environment variables from the command line
- Command line to remove an environment variable from the OS level configuration
- What is the smallest possible Windows (PE) executable?
- Find absolute java.exe path programmatically from java code
- Adding path permanently to windows using powershell doesn’t appear to work
- How do I add to the Windows PATH variable using setx? Having weird problems
- Python executables: py2exe or PyInstaller?
- Windows PATH to posix path conversion in bash
- “invalid path 0 files copied” Error while using xcopy command
- how to get program files x86 env variable?
- Can I set an environment variable for an application using a shortcut in Windows?
- Remove unwanted path name from %path% variable via batch
- Hide Command Window of .BAT file that Executes Another .EXE File
- How do I get current date/time on the Windows command line in a suitable format for usage in a file/folder name?
- Map a network drive to be used by a service
- IE10 renders in IE7 mode. How to force Standards mode?
- Why does %date% produce a different result in batch file executed as scheduled task?
- GIT clone repo across local file system in windows
- How do you run a crontab in Cygwin on Windows?
- Graphviz: How to go from .dot to a graph?
- Batch script loop
- Git for Windows: .bashrc or equivalent configuration files for Git Bash shell
- What is the difference between mutex and critical section?
- Should I redistribute msvcrt.dll with my application?
- How to make git ignore changes in case?
- Create list or arrays in Windows Batch
- How to create Windows EventLog source from command line?
- How do I get the current username in Windows PowerShell?
- Windows equivalent to UNIX pwd
- Dealing with quotes in Windows batch scripts
- Why %processor_architecture% always returns x86 instead of AMD64
- Batch to remove duplicate rows from text file
- Global NPM package installed but command not found