Although Windows has supported fancy filenames nearly forever, I find that they can still cause problems. Of particular trouble on the x64 OS are PATH variables which contain “C:\Program Files (x86)”. The parenthesis can cause scripts to die with error messages like “\Microsoft was unexpected at this time.”
I found a cute hack on the newsgroups that helps deal with this. Below is a script which will sanitize a PATH variable, cleaning up all that troublesome stuff.
@echo off
setlocal enabledelayedexpansion
set FIXED=
FOR %%I IN ("%PATH:;=" "%") do (
set FIXED=!FIXED!%%~fsI;
)
for %%D in (a) do (
endlocal
set PATH=%FIXED%
)

0 Responses to “A Straight and Narrow %PATH%”
Leave a Reply