Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > VB Script

Vista - creating Environment variable during logon script

Reply
 
Old 12-15-2008   #1 (permalink)
Elgordo


 
 

creating Environment variable during logon script

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

My System SpecsSystem Spec
Old 12-15-2008   #2 (permalink)
Pegasus \(MVP\)


 
 

Re: creating Environment variable during logon script


"Elgordo" <Elgordo@xxxxxx> wrote in message
news:521596E0-978E-4139-8446-8AC66F3C5784@xxxxxx
Quote:

> 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



My System SpecsSystem Spec
Reply

Thread Tools


Similar Threads
Thread Forum
Creating logon scripts - the script will map different sets of drivesdepending on the security grp the user is in. VB Script
environment variable not seen Software
Call PS Script with Environment Variable in Path via Command Line PowerShell
how to set environment variable where name is not a-z nor A-Z PowerShell
how to set environment variable where name is not a-z nor A-Z PowerShell


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46