Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.

Author Topic: System varibles  (Read 3389 times)

0 Members and 1 Guest are viewing this topic.

David_DBA

  • Guest
System varibles
« on: March 24, 2005, 06:03:35 AM »
 ???
Hello
I want to write a script for windows to edit the system variables. Does anyone knowed how can I get to the Windows system variable??
Tnks

David

Sidewinder



    Guru

    Thanked: 139
  • Experience: Familiar
  • OS: Windows 10
Re: System varibles
« Reply #1 on: March 24, 2005, 09:11:52 AM »
This might help. Note: MYVAR is just arbitrary name I made up.

Dim WshShell, WshEnv
Set WshShell = WScript.CreateObject("WScript.Shell")
Set WshEnv = WshShell.Environment("SYSTEM")

To set the MYVAR variable use:

WshEnv("MYVAR") = "Any Value"

To remove the MYVAR variable use:

WshEnv.Remove "MYVAR"

If you use the SET command from the command line, you will get a list of all variables defined in the environment. If you need new ones, just make one up and change MYVAR accordingly. Any changes/additions made, only last as long as the user session.


Hope this helps.  8)
« Last Edit: March 24, 2005, 09:15:17 AM by Sidewinder »
The true sign of intelligence is not knowledge but imagination.

-- Albert Einstein