Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Login script reliability

Status
Not open for further replies.

GDameron

Programmer
Aug 8, 2003
39
US
I'm attempting to set an environment variable (without using the System control panel) so that every user who logs on has it set. This is on a Win2K server SP4 running standalone (no clients). My login vbs script is something akin to:
Code:
Dim shell
Dim volEnv
Set shell = Wscript.CreateObject("Wscript.Shell")
Set volEnv = shell.Environment("VOLATILE")
volEnv("TEST_VOLATILE") = "test_value"
Wscript.echo volEnv("TEST_VOLATILE")
I added the vbs to the local group policy. No other group policy login scripts (domain, etc.) are defined.

When I login, either as admin or as a "mortal" user, the script runs fine -- I get the expected wscript popup displaying the echoed value. So far, so good.

The problem occurs when I open a new command prompt window and do a "set" command. I would expect to see my environment variable listed. But that's not always the case. If I've logged on as admin, it's there nearly every time, but not always. If I've logged on as a "mortal" user, it's there some of the time, perhaps one in five logons, with better chance of success right after a boot.

Seems strange to me -- I was hoping for better reliability than this. Timing problem, perhaps? Faulty assumption?

GD
 
Have you tried SYSTEM or USER instead of VOLATILE ?

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
i couldnt get a reliable solution, thought i had it licked but wxp sp2 kicked me in the nuts, i try

WshShell.RegWrite "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment\NewVariable", "Hello", "REG_SZ"
'this is just to prompt windows into thinking it needs
' to refresh the environment, rather then a SendMessage API
'call
Dim WshSySEnv
Set WshSysEnv = WshShell.Environment("SYSTEM")
WshSysEnv("tempvar") = "123"
Set WshSySEnv = Nothing
 
Using SYSTEM certainly works. Two followup questions:

1. Is VOLATILE known to be unreliable under Win2K?

2. Is there a VBS way to delete a self-created SYSTEM variable?

GD
 
2. Take a look at the Remove method of the WshEnvironment object:
WshSysEnv.Remove "tempvar"

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top