VBS and Environment Variables
Hi all, I have encountered a really weird incident.
One of the software I am packaging for deployment requires an update. So, like normally, I packaged the exe file for install and all. then call the update, which apparenlty is a .bat file.
Well to make the problem short, a System Enivornment Variable is set by the exe setup file, where this environment variable is needed by the update batch file.
However, in the script I am running, the batch file doesn't pick up the environment variable changes.
Funny thing is, when I pause the vbs script, and start a CMD session, that picked it up. So, the updates would work if I ran it again.
Hence, my problem seems to be boiling down to the case of renewing the environment Variables after setup.exe has been ran.
Oh, I've tried the following...
Setting the Environment Variables within the VBS script before calling the batch file.
Taking the Batch file updates in a new file, where i launch a new 'wscript' instance within my vbs to run it.
setting the current Setting the current wshell object to nothing, and recreate to run the batch files.
All attempts so far seems to have failed.
Any suggestions?
One of the software I am packaging for deployment requires an update. So, like normally, I packaged the exe file for install and all. then call the update, which apparenlty is a .bat file.
Well to make the problem short, a System Enivornment Variable is set by the exe setup file, where this environment variable is needed by the update batch file.
However, in the script I am running, the batch file doesn't pick up the environment variable changes.
Funny thing is, when I pause the vbs script, and start a CMD session, that picked it up. So, the updates would work if I ran it again.
Hence, my problem seems to be boiling down to the case of renewing the environment Variables after setup.exe has been ran.
Oh, I've tried the following...
Setting the Environment Variables within the VBS script before calling the batch file.
Taking the Batch file updates in a new file, where i launch a new 'wscript' instance within my vbs to run it.
setting the current Setting the current wshell object to nothing, and recreate to run the batch files.
All attempts so far seems to have failed.
Any suggestions?
0 Comments
[ + ] Show comments
Answers (1)
Please log in to answer
Posted by:
anonymous_9363
16 years ago
That's the thing with System variables: they're only visible to the process which created them or to new processes. It's why I almost never use them, preferring instead to use User variables. It's also why I suspect the original EXE triggers a system restart, so that all processes see the new variable.
If all you need to do is make sure that it got created, you can interrogate the relevant registry entry, HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment\[your variable name]
If all you need to do is make sure that it got created, you can interrogate the relevant registry entry, HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment\[your variable name]
Rating comments in this legacy AppDeploy message board thread won't reorder them,
so that the conversation will remain readable.
so that the conversation will remain readable.