Home NT WSH
WshShell.Environment.Remove

Remove an NT environment variable.

Syntax 
      WshShell.Environment(strType).Remove(strName)

Arguments:
      strString is the environment variable 
                to be removed

      strType is one of
              "System" (HKLM),
              "User"   (HKCU),
              "Volatile" or "Process"

Example

' Delete the LAST_LOGIN_DATE user environment variable
Set WshShell = Wscript.CreateObject("Wscript.Shell")

WshShell.Environment("USER").Remove("LAST_LOGIN_DATE") 

Note: for anything other than USER variables - the user needs permissions to delete the variable. Environment variables removed with the Remove method are not removed permanently; they are only removed for the current session.

I'm sorry Dave... I can't do that. - HAL 9000 (2001: A Space Odyssey)

Related commands:

Environment, read env variables - WshShell.Environment

Equivalent Windows NT command:

SET - Display, set, or remove Windows NT environment variables



Back to the Top

Simon Sheppard
SS64.com