RE: Environment issue's Please help
- From: \RemS <RemS@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Sun, 20 May 2007 02:38:00 -0700
"Rogier" wrote:
Hi all,
i have the following problem
sorry my english is not that great.
I have 1 vbscript in with 2 things happen
1: install an MSI if not installed
2: if MSI is installed execute the advertised shortcut.
the script works great but we have one issue
If the MSI (we take ORACLE for example) set or expands a windows
systems variable like the "Path=%Path%;C:\Oralce" the seconde action
of the script doen't expands environment variables like the path en
ORACLE gives a error becourse the path is nog found.
This is becourse the vbscript doen't expands the new installed windows
variable.
my question is how can I expand reload the windows environment
variables in a running VBSCRIPT?
i have many workarrounds like putting the environments in a
logonscript and solutions like that but I want 1 vbscript.
can anybody help me i am not that great with vbscipt.
greatings
Roger
Hoi Rogier,
Normaly with
WSHShell.Environment.item("nwVariableName") = ....
you can set the System variable during a session.
It will: 1- wright to registry
2- udate the session environment
3- delete from registry (!)
Now you can use the variable.
But to make it permanent you have to write it again to the registry after 10
! seconds or something:
"HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Environment\"
And make sure this part of the script only run once.
note:
When you want to write it afterwards to registry to make it persistent, you
have to *exand the current variable* first and add the new value to the
string, then write the *complete* string to the registry.
note also that Only members of the local administrators group can set system
environment.
"Any user can add, modify, or remove a user environment variable. However,
only an administrator or systemaccount can add, modify, or remove a system
environment variable"
http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/environment_variables.mspx?mfr=true
-!- So you cannot use the method above with a user logon script -!-.
The best way to add an entry to the %path% system variable,
is to create "path" ALSO as user variable,
with the string value: %path%;nwVariableName
(it reads the systemvalue to)
To add and to ACTIVATE new environment variables you need a thirdparty tool
"SetEnv.exe"
like this:
Set objShell = CreateObject("WScript.Shell")
strSettings = "...."
objShell.Run "path\SetEnv.exe " & strSettings, 0, True
Set objShell = Nothing
On the internet you can find TWO versions of that tool:
1. SetEnv.exe (lighter than the other one)
- http://www.codeguru.com/cpp/w-p/win32/tutorials/article.php/c10849
- http://www.codeguru.com/cpp/w-p/win32/tutorials/article.php/c10849
OR:
2. SETENV.EXE (this one has more functionality)
- http://www.jsifaq.com/sf/tips/tip.aspx?id=4928
- http://www.windowsnetworking.com/nt/atips/atips343.shtml
\Rems
.
- Follow-Ups:
- Re: Environment issue's Please help
- From: Rogier
- Re: Environment issue's Please help
- References:
- Environment issue's Please help
- From: Rogier
- Environment issue's Please help
- Prev by Date: Re: a setTimeOut question
- Next by Date: Server side XML / XSL Transformation
- Previous by thread: Environment issue's Please help
- Next by thread: Re: Environment issue's Please help
- Index(es):
Relevant Pages
|