How do I set the global PATH environment in a batch file?
The group policy in our environment overwrites the PATH variable every time I log on and, as I run a 'non-standard' computer, it gets it completely wrong (C:\Windows vs C:\WINNT, missing directories etc). Currently, I manually change it every time I log on, but that is starting to get tiresome.
If I use the SET command to change the PATH variable in a batch file, it only has local scope so the change only applies to the commands in the batch file.
set PATH=C:\WINNT;C:\WINNT\System32
set PATH
This batch file will output the new path, but if I run set PATH
on the command line afterwards, it will still be the original path.
How do I set the global PATH environment in a batch file? Or is there another technique I can use?
Solution 1:
You can use the setx command:
setx PATH C:\WINNT;C:\WINNT\System32 /m
Setx is available in Windows 2003 and later, but can be downloaded in the Support Tools for Windows XP.