• We’re currently investigating an issue related to the forum theme and styling that is impacting page layout and visual formatting. The problem has been identified, and we are actively working on a resolution. There is no impact to user data or functionality, this is strictly a front-end display issue. We’ll post an update once the fix has been deployed. Thanks for your patience while we get this sorted.

Append system path variable

lokiju

Lifer
I'm looking for the cleanest and easiest way to append to the Path variable under System Variables under Environment Variables in Windows OS's.

I've Google'd around for ways to do this with Powershell, command prompt commands and editing the registry.

While editing the registry directly with my own interactions is an option, I'm trying to figure out how to script this so I can apply it on a large scale.

The registry path is HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment\Path

Has anyone done this before successfully and know a scrip/command/method for accomplishing this?

The key thing is I'm trying to APPEND to the existing system path, not overwrite what's already there.

Thanks.
 
You can get the contents from the registry using reg query, manipulate the string through your script, then update value with a reg add.

One issue to be aware of is that the OS does not realize the value has been modified so it does not issue an event to the shell to reload the contents of that registry key. You may have to reboot or logout/login for the new values to be detected.
 
If you can get a hold of a copy of Windows PowerShell 2.0 Administrator's Pocket Consultant, the author goes into detail of how to do this with the SETX command on page 58.
 
Even if you edit the registry manually you'll need to refresh the environment somehow, usually by forcing the user to log off and back on again. The system control panel seems to have some magic that updates it for the current session in their Apply button code, but I don't know how they do it.
 
If you can get a hold of a copy of Windows PowerShell 2.0 Administrator's Pocket Consultant, the author goes into detail of how to do this with the SETX command on page 58.

I think I might actually have that handy somewhere.

I'll look it over.
 
Back
Top