I am using the WshEnvironment class to retrieve the PATH environment value (and append to it), and then save it back. However, the change to the path doesn't seem to take effect until the user logs out and back in again... or reboots the PC. I have verified the value gets set via the "My Computer | Properties | Advanced | Environment Variables" applet, and then checked the PATH value via a command prompt.
After the user logs out and back in again, the command prompt PATH command reflects the correct path.
This is the code I am using:
Any suggestions on how to update the PATH value in real time? Is it even possible?
Dim objHost As WshShell
Dim objEnv As WshEnvironment
Dim strExistVal As String
' Get existing var
Set objHost = New WshShell
Set objEnv = objHost.Environment("SYSTEM")
strExistVal = objEnv("PATH")
' tack on the additional path
strExistVal = strExistVal & ";C:\AnotherFolder;"
objEnv(strEnvVarName) = strExistVal