RE: Environment issue's Please help





"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
.



Relevant Pages

  • Re: Warp Rogue - SDL help wanted
    ... and the JRE isn't trivialy sized either. ... install those wierd things". ... environment variables, ... GodMode: Boolean = False; ...
    (rec.games.roguelike.development)
  • Re: DBD-SQLAnywhere-1.16
    ... Before you can bring up the server version using "dbsrv10" You have to install the environment variables ... Then bring up the server with "dbsrv10 -n demo10 /opt/sqlanywhere10/demo.db -ud". ... I don't have DBD::SQLAnywhere installed at all - I only thought a) there may be some failures in the test results that you'd find useful and b) you didn't actually tell us what did not work. ...
    (perl.dbi.users)
  • RE: Office 2007 Install Error 2203
    ... Sorry for this delayed response due to the weekend. ... It seems that re-set the environment variables fixed this issue. ... guess was that Windows used C:\Temp as a temporary folder used for the ... Since you can install and run Office 2007 Beta without a ...
    (microsoft.public.office.setup)
  • Re: Turn off a desktop toolbar
    ... Unfortunately, there's no general way to this with VBScript, so you've got the most general solution. ... The return value from the function is the exit errorcode for regsvr32. ... rem Turn off Nero Scout and remove the search bar if Nero 7 is installed ... When we installed it we applied customizations to the install to remove a bunch of the consumer stuff, but could not disable the Nero Search toolbar. ...
    (microsoft.public.scripting.vbscript)
  • Re: preparing for the next open-source gfortran release
    ... under a new account, you should not get the problem. ... The distribution 4.3.0-20080127 does not have g++. ... This is problem of environment variables. ... install two distributions on Windows. ...
    (comp.lang.fortran)