How to set static user variable with VBScript 
Author Message
 How to set static user variable with VBScript

I've looked everywhere trying to find out if this is possible.  I would like
to be able to set the user TEMP and TMP environment variables from a logon
script.  Is this possible with VBScript?  If not, does anyone have any
suggestions on how I might go about doing this?

Thanks,
Scott



Mon, 10 May 2004 15:25:59 GMT  
 How to set static user variable with VBScript

Setting environment variables permanent:

Example for setting a environment variable with name "ASSET" and value "1234"

For WNT/W2k/WXP:

Set WshShell = CreateObject("WScript.Shell")

' makes environment settings permanent and for all users
Set WshSystemEnv = WshShell.Environment("SYSTEM")

' Set your environment variable
WshSystemEnv("ASSET") = "1234"

For W9x/ME:

You must add a "SET asset=1234" line in autoexec.bat

--
torgeir

Quote:

> I've looked everywhere trying to find out if this is possible.  I would like
> to be able to set the user TEMP and TMP environment variables from a logon
> script.  Is this possible with VBScript?  If not, does anyone have any
> suggestions on how I might go about doing this?

> Thanks,
> Scott



Mon, 10 May 2004 17:20:39 GMT  
 How to set static user variable with VBScript
Nevermind.  I found the answer.  Just in case anyone else was wondering,
here's the answer.

Set WshShell = WScript.CreateObject("Wscript.Shell")
Set WshEnv = WshShell.Environment("USER")
WshEnv("TEMP")= "C:\TEMP"
WshEnv("TMP")= "C:\TEMP"

Hope that helps somebody.

Scott



Mon, 10 May 2004 18:12:25 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. How do I set a static variable value?

2. How do you set the initial value of a Static variable

3. Static variable not static enough ???

4. Set location - how to alter the variables Database: and User ID:

5. Setting Static IP

6. Static variables in VBS?

7. Static variable?!

8. How to create a static variable?

9. Static Variables

10. Static Variable?!

11. Adding new VPN users and assigning static IP addresses via VBS

12. How set an environment variable with vbscript?

 

 
Powered by phpBB® Forum Software