Re: creating Environment variable during logon script
- From: "Pegasus \(MVP\)" <I.can@xxxxxxxxxx>
- Date: Mon, 15 Dec 2008 22:46:05 +0100
"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
.
- References:
- creating Environment variable during logon script
- From: Elgordo
- creating Environment variable during logon script
- Prev by Date: creating Environment variable during logon script
- Next by Date: Re: Print to PDF
- Previous by thread: creating Environment variable during logon script
- Index(es):
Relevant Pages
|