in reply to Cleaning %PATH% with WinBatch
However, it's a little bit tricky to set the environment permanently. You would have to use 'setx' instead of set or include this last line:@echo off setlocal EnableDelayedExpansion ::set path echo PATH OLD %PATH:;=&echo.% set $line=%path% set $line=%$line: =#% set $line=%$line:;= % set $line=%$line:)=^^)% echo FOUND for %%a in (%$line%) do @echo %%a | find /i "C:\perls" || set $newpath +=!$newpath!;%%a echo. set $newpath=!$newpath:#= ! set $newpath=!$newpath:^^=! set path=!$newpath:~1! echo PATH NEW %PATH:;=&echo.%
endlocal & set path=%$newpath:~1%
|
|---|