Remove a Windows environment variable.



   objShell    A WScript.Shell object

   strString   The environment variable 
               to be removed

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


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

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 VBScript commands

Environment, read env variables - .Environment
Equivalent Windows CMD command: SET - Display, set, or remove environment variables.
Equivalent PowerShell cmdlet: Get-Item env:HOMEDRIVE or $env:HOMEDRIVE

Copyright © 1999-2024 SS64.com
Some rights reserved