Re: creating Environment variable during logon script

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance




"Elgordo" <Elgordo@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:521596E0-978E-4139-8446-8AC66F3C5784@xxxxxxxxxxxxxxxx
Hello
I am trying to create an environment variable that executes during the
logon
script , I can get it to create the variable during execution however ,
when
I go to the cmd prompt and type SET the environment variable is not
present.
below is the subscript that I am calling from the main logon script

Dim WSHShell
Set WSHShell = WScript.CreateObject("WScript.Shell")

'WScript.Echo "The current PATH is " & _
' WSHShell.Environment.item("path")

'WScript.Echo "Creating a new environment variable called
SAPLOGON_INI_FILE"
' this variable will exist only during execution
' time of this script (Win95)
WSHShell.Environment.item("SAPLOGON_INI_FILE") =
"\\ca-mir-data01\Nss\SAPlogon\saplogon.all"
wScript.Echo "SAPLOGON_INI_FILE is " & _
WSHShell.Environment.item("SAPLOGON_INI_FILE")

Set WSHShell = Nothing

Here are a few options to create non-transient environmental variables:
- Use setx.exe (Windows Resource Kit)
- Use setenv.exe (ftp://barnyard.syr.edu/pub/vefatica/setenv.exe)
- Modify the script below (from a post by Ruediger Roesler)

Set oWsShell = CreateObject("WScript.Shell")
For Each strEnv In Array("PROCESS", "SYSTEM", "USER", "VOLATILE")
WScript.Echo VbCrLf & VbCrLf & strEnv & "-Environment:" & VbCrLf
For Each str In oWsShell.Environment(strEnv)
WScript.Echo str
Next
Next

str = WScript.ScriptName
Set oWshUEnv = oWsShell.Environment("User")

WScript.Echo VbCrLf
WScript.Echo "Create variable '" & str & "' in Environment 'User':"
oWshUEnv(str) = CStr(Date)
WScript.Echo VbCrLf & str & ": " & oWshUEnv(str)

oWshUEnv.Remove str
If Len(oWshUEnv(str)) = 0 Then
WScript.Echo "Environment variable '" & str & "' was removed."
Else
WScript.Echo "Environment variable '" & str & "' wasn't removed."
End If



.



Relevant Pages

  • Re: How do implement this wildcard?
    ... The "x" makes the script robust so that it does not fail in the line below ... for environmental variables, ... The script determines whether or not the parameter is a UNC, ... significantly more difficult to determine using batch alone. ...
    (microsoft.public.windows.server.scripting)
  • Re: Unexpected retrieved value in Environment Varaibles
    ... dirty little hardware inventory script that I call from the main login ... Pentium4 CPU 3.00GHz Winnipeg ... WPGAGEDKAREN-H2 Microsoft Windows XP Professional Intel ... I tend to obtain my environmental variables like so: ...
    (microsoft.public.scripting.vbscript)
  • Re: system ("source ...");
    ... I want to set some environmental variables in order to be visible ... > to the script children programs. ... I consider putting them in a different perl script using %ENV. ... one Perl file in another, you want either do, require, or use, again ...
    (perl.beginners)
  • Re: How do implement this wildcard?
    ... The "x" makes the script robust so that it does not fail in the line below ... for environmental variables, ... Every process, whether it is a Command Processor or some other executable, ... You need to execute a ...
    (microsoft.public.windows.server.scripting)
  • Defining environment variables and cgi scripts
    ... I have a cgi script I want apache to execute for me. ... The problem I'm having is I don't know how to include editional environmental variables that the script requires. ... How do I add a variable called PAYMENTIC_HOME to the list of environment variables that perl knows about when executing a script under apache? ...
    (Debian-User)