Results 1 to 2 of 2

Thread: Remove system environment variable using command line ?

  1. #1
    Vilius Mockûnas Guest

    Remove system environment variable using command line ?

    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



  2. #2
    Pegasus [MVP] Guest

    Re: Remove system environment variable using command line ?


    "Vilius Mockûnas" <v_mockunas@yahoo.com> wrote in message
    news:uOmTtc06JHA.5828@TK2MSFTNGP04.phx.gbl...
    > 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



Similar Threads

  1. How to Enable system protection from command line
    By Abhaa in forum Operating Systems
    Replies: 4
    Last Post: 30-01-2011, 06:47 PM
  2. Importance of Command Line User Environment in Linux
    By aFRODITA in forum Operating Systems
    Replies: 4
    Last Post: 12-11-2010, 07:31 AM
  3. Replies: 5
    Last Post: 11-11-2010, 11:10 AM
  4. Replies: 2
    Last Post: 01-04-2009, 05:46 PM
  5. system restore from command line
    By merrittr in forum Windows XP Support
    Replies: 7
    Last Post: 27-08-2008, 12:45 AM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,711,689,521.62557 seconds with 17 queries