RemS
Thu May 24 18:52:01 CDT 2007
"Rogier" wrote:
> On May 21, 12:02 pm, \RemS <R...@discussions.microsoft.com> wrote:
> > "Rogier" wrote:
> > > Yeah this is the wa to do it from a script i know this.
> >
> > > Problem lies in the fact that the MSI installs the environment not the
> > > script in with i first run a MSI and then the App installed with de
> > > MSI.
> >
> > > If the MSI contains a environment variable it is set bij de MSI and it
> > > is active to use but mij parent VBS script is still running with the
> > > old environments.
> >
> > > Thanks for youre comment but this is not the solution to my problem.
> > > I need te find a way to update de environments from my parent VBS
> > > script.
> >
> > > anybody?
> >
> > The tool SetEnv.exe WILL UPDATEs all the variables to the New Environment
> > (see the links in my previous reply). That is what makes the tool special.
> >
> > There can *only be one* environment current per computer/user, So it is not
> > possible the parent/initiating VBS script is still running with the old
> > environments, unless the initiating script reads the "previous" environment
> > variable only once and set it as a parameter with its own name, and the
> > script continue using the parameter name instead of keepon re-reading the
> > environment variable? OR Else something goes wrong trying to set the new
> > environment and was not succesful.
> >
> > To help you with this, we have to take a look at both scripts.
> >
> > \RemS- Hide quoted text -
> >
> > - Show quoted text -
>
> Again I know how to set it with scripting but can use this tool,
> nut if you read my post i want to set it with MSI so not from a
> script.
>
> the MSIEXEC does not return the new variables so to the parent.
>
Rogier, I guess you misunderstood my replies, they weren't about "I know
what you don't know".
It more likely the other way around in some points. You could have taken the
opertunity to tell us what you *actualy have tried* so far. And, it could
also be usefull if you mensioned what environment level exactly is configured
during the MSIEXEC install User | Machine | default user | Volatile env (->
depends in which registrykey the value is added). Or, maybe, the environment
is enhanced by a process everytime?.
And, how is the script trying to expand the value now, and how exactly is
that used further in the script.
But, apart from that, you are correct;
- the MSI package installation probably already takes care for updating the
environment.
- but it only cannot RETURN the new variables to the parent. That vbs uses
and
passing the originating variables that was current on the time the script
was
executed.
~ ~ ~
You are lucky if the environment variable value is set or added in one of
the two keys below;
HKLM\System\CurrentControlSet\Control\
Sessionmanager\Environment
OR
HKEY_USERS\<user>\Environment
In that case you can use the WMIService to query the Environment:
(even w/out the use of SetEnv.exe first)
'---------------------------
enVariable1 = "path"
strComputer = "."
Set objWMIService = GetObject( _
"winmgmts:\\" & strComputer & "\root\cimv2")
Set colVar = objWMIService.ExecQuery( _
"Select * from Win32_Environment where Name = '"& enVariable1 &"'")
For Each objVar in colVar
varValue1 = objVar.VariableValue
' exit For
Next
Set WshShell = WScript.CreateObject("WScript.Shell") '<--- optional
wscript.echo WshShell.ExpandEnvironmentStrings(varValue1)
'---------------------------
If not in these registrykeys, then i'm afraid there is no solution :(
I hope the Win32_Environment works for you.
grtz.
~ ~ ~
"For others who reads this topic and are intrested in SetEnv.exe ...."
The tool SetEnv.exe is able to force a *reload of the environment* w/out
re-logon or the need for a reboot.
It can be executed after changes were made to one of the 4 environment keys
in the registry.
The tool can runned from a vbscript like this for example:
enVariable = "PATH"
Set WshShell = WScript.CreateObject("WScript.Shell")
strProg = "\\unc-or-localpath\SetEnv.exe"
WshShell.Run chr(34) & strProg & chr(34) & " $fake$ -delete",0 , TRUE
'(for that you have to use this version of SetEnv.exe !:
'
http://www.codeguru.com/cpp/w-p/win32/tutorials/article.php/c10849
' btw this the one with more functionality, I mixed both up in my first
reply)
This script will refresh the environment for every new script and every
application on this computer runned afterwards. But it canNOT change the
environment for the script itself and it will even passing that old
environment to the scripts that were, and to scripts that are going to be
executed by this script, and even the scripts that were executed by the
scripts or batches that were executed from within the initiation script are
still in the 'old' environment !!!
\RemS