Created
December 12, 2017 14:30
-
-
Save PSingletary/5239e6813de60c8057e6ccb72d7a804f to your computer and use it in GitHub Desktop.
convert entries in PATH to 8.3 format to gain more character space
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
REM http://stackoverflow.com/questions/4405091/how-avoid-over-populate-path-environment-variable-in-windows | |
@echo off | |
SET shortpath=%PATH% | |
echo "Old PATH documented in C:\_admin\OLDPath.txt" | |
echo %shortpath% | |
echo %shortpath% > C:\_admin\OLDPath.txt | |
echo -- | |
echo "Directories not found, documented in C:\_admin\PATH_folders_not_found.txt" | |
echo -- | |
setlocal EnableDelayedExpansion | |
SET TempPath="%shortpath:;=";"%" | |
SET var= | |
FOR %%a IN (%TempPath%) DO ( | |
IF exist %%~sa ( | |
SET "var=!var!;%%~sa | |
) ELSE ( | |
echo %%a does not exist >> C:\_admin\PATH_folders_not_found.txt | |
) | |
) | |
echo -- | |
echo "Shortened PATH documented in C:\_admin\NEWPath.txt" | |
echo -- | |
echo !var:~1! | |
echo !var:~1! > C:\_admin\NEWPath.txt | |
echo -- | |
echo "Open C:\_admin\NEWPath.txt, Open regedit, Navigate to HKLM\System\CurrentControlSet\Control\Session Manager\Enviroment, Dobule click on Path, copy in contents of C:\_admin\NEWPath.txt, Click OK, reboot PC, Validate change." |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment