/build/static/layout/Breadcrumb_cap_w.png

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?

0 Comments   [ + ] Show comments

Answers (1)

Posted by: anonymous_9363 15 years ago
Red Belt
0
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]
Rating comments in this legacy AppDeploy message board thread won't reorder them,
so that the conversation will remain readable.
 
This website uses cookies. By continuing to use this site and/or clicking the "Accept" button you are providing consent Quest Software and its affiliates do NOT sell the Personal Data you provide to us either when you register on our websites or when you do business with us. For more information about our Privacy Policy and our data protection efforts, please visit GDPR-HQ