Re: Can VBS read an environment variable? by \
\
Thu Jun 08 07:07:09 CDT 2006
> We have a vbs script that has hardcoded a destination folder, including
> drive letter. Unfortunately, our servers sometimes have the destination on
> the C: drive and others may, for example, be on an F: drive. I am thinking
> the way to generalize the script would be to set a global environment
> variable and instead of hardcoding the drive, substitute the environment
> variable value instead.
> Does anyone know if this is doable?
Yes. This is for an environment variable named "Target" assigned to the system,
and thus the same for all users logged on to that computer.
Set WshShell = WScript.CreateObject("WScript.Shell")
Set WshSysEnv = WshShell.Environment("SYSTEM")
WScript.Echo WshSysEnv("Target")
If you want to assign the target on a per user basis, enter the environment
variable in the "user" section and change SYSTEM above to USER.
--
Crash
"In statesmanship get the formalities right, never mind about the moralities."
~ Mark Twain ~