Windows Vista Tips

Windows Vista Tips > Newsgroups > Windows Server > Scripting > Remove system environment variable using command line ?

Reply
Thread Tools Display Modes

Remove system environment variable using command line ?

 
 
Vilius Mockūnas
Guest
Posts: n/a

 
      06-12-2009
Hello,

How do I remove system environment variable using command line ?
For example I can add it using:
setx y 10 -m
But from setx documentation:
"You cannot use setx to remove values added to the local or system
environments."

(I know how to remove using GUI but this is not the case)

thanks
Vilius


 
Reply With Quote
 
 
 
 
Pegasus [MVP]
Guest
Posts: n/a

 
      06-12-2009

"Vilius Mockūnas" <> wrote in message
news:...
> Hello,
>
> How do I remove system environment variable using command line ?
> For example I can add it using:
> setx y 10 -m
> But from setx documentation:
> "You cannot use setx to remove values added to the local or system
> environments."
>
> (I know how to remove using GUI but this is not the case)
>
> thanks
> Vilius


The following script will first set, then remove the system variable %XVar%:
Set wshShell = CreateObject("WScript.Shell")
Set wshSEnv = wshShell.Environment("System")
sMyVar = "XVar"
wshSEnv(sMyVar) = "Vilius"
WScript.Echo "Variable " & sMyVar & " is now set to Vilius"
wshSEnv.Remove sMyVar


 
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Remove system environment variable using command line ? Vilius Mockūnas Windows Server 1 06-12-2009 10:40 AM
Vista UAC pops up a new Command window and my environment variable islost Bo Windows Vista General Discussion 3 01-13-2009 06:28 PM
Re: Remove environment variable Michael Harris \(MVP\) Scripting 0 01-07-2005 09:30 PM
read variable value from command line cabua99 Scripting 2 01-27-2004 01:23 PM
Passing Variable to Command Line Ernie Scripting 1 08-15-2003 09:03 PM



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 47 48 49 50 51 52 53 54 55 56 57 58 59