Windows path doesn't contain C:\WINDOWS\system32, can I add it using batch script? -


i writing batch script that, quite reasonably, depends on "c:\windows\system32" being part of path environment variable. encountered (developer's) machine had weird path didn't include system32, , therefore batch script didn't work.

i looked ways batch script check path variable , add system32 if not there. however, solution found used setx ironically enough depends on system32 in path variable. there programmatic ways add system32 path without being there?

also please let me know if such edge case doesn't make sense make script robust against it. i'm not expecting of typical users have such borked path variable. should bother?

try this:

for /f "delims=" %%a in ("%comspec%") set "path=%path%;%%~dpa" 

or this:

for /f "delims=" %%a in ("%comspec%") set "compath=%%~dpa" set "path=%path%;%compath:~0,-1%" 

Comments

Popular posts from this blog

plot - Remove Objects from Legend When You Have Also Used Fit, Matlab -

java - Why does my date parsing return a weird date? -

Need help in packaging app using TideSDK on Windows -