I'm running a VBScript from a MSI installer (created using WiX toolset). This script checks using the PATH environment variable whether another software is installed or not. The installer also offers a retry button which runs the script again.
Now the problem is this: If the PATH environment variable is changed while my installer is running, my script will not detect that change. My script only uses the new value of the PATH environmental variable after a re-start of the installer.
So the question is this: How can I force the installer process to update its copy of the environment variables using VBScript?
Edit:
It looks like this article explains how to solve the problem with PowerScript. But I need a solution for VBScript.
With WScript.CreateObject("WScript.Shell")
.Environment("PROCESS")("PATH") = .ExpandEnvironmentStrings(Replace( _
.Environment("USER")("PATH") & ";" & .Environment("SYSTEM")("PATH"), ";;", ";" _
))
End With
This will overwrite the in memory current process PATH
environment variable with the information retrieved from registry for the user
and system
environment variables.
note: Previous code only updates the environment copy of the [c|w]script
process that executes the code. It does not update the installer's copy of the environment (you can not update another process environment).