- Jeff
"Peter Grant" <peter...@unisys.com> wrote in message
news:8jbfo9$r1i$1...@mail.pl.unisys.com...
> Trying to set the variable %TMP% to the output of a file called siteid
> (which = 400)
> how do i do this?
>
>
>
Set WshShell = CreateObject ("WScript.Shell")
' get the collection using the Environment property
Set objEnv = WshShell.Environment("Process")
' create a (temporary) environment variable
objEnv("Born") = "Hello World!"
' Read environment variables
Message = ""
For Each i In objEnv
Message = Message & i & vbCRLF
Next
WScript.Echo Message
But keep in mind that creating environment variables from a script
creates only temporary values (the values are getting lost after terminating
the script).
G. Born
_________________________________________
Check out the WSH Bazaar at www.borncity.com
"Peter Grant" <peter...@unisys.com> schrieb im Newsbeitrag
news:8jbfo9$r1i$1...@mail.pl.unisys.com...
Any Ideas??
Rdgs
"GBorn" <GB...@borncity.de> wrote in message
news:eD502UM4$GA.76@cppssbbsa05...
Set WshShell = WScript.CreateObject("WScript.Shell")
Set WshProcessEnv = WshShell.Environment("PROCESS")
Set WshUserEnv = WshShell.Environment("USER")
'SYSTEM not valid on Win2k for TMP
Set WshSysEnv = WshShell.Environment("SYSTEM")
'if you write %SystemDrive% with WSH you will get %SystemDrive% not c:\
'so all variables must be expanded before being written to the environment
'WshShell.ExpandEnvironmentStrings("%SystemDrive%\TEMP")
WshProcessEnv("Test") = "Hello"
WshUserEnv("Test") = "Hello"
WshSysEnv("Test") = "Hello"
MsgBox "Process: " & WshProcessEnv("Test") & _
vbCRLF & _
"User: " & WshUserEnv("Test") & _
vbCRLF & _
"System: " & WshSysEnv("Test")
'Cleanup
WshProcessEnv.Remove("Test")
WshUserEnv.Remove("Test")
WshSysEnv.Remove("Test")
'If you want to run a program from your script
'with the new environment you need to set
'Process environment and User (User to make it permanent)
'If you don't set the Process environment then you will run
'the program with whatever environment your script started in
David Hamel
Peter Grant <peter...@unisys.com> wrote in message
news:8jcjhe$7aa$1...@mail.pl.unisys.com...