刪除現(xiàn)有的環(huán)境變量。
object.Remove(strName)
Remove 方法從 PROCESS、USER、SYSTEM 和 VOLATILE 四種類型的環(huán)境中刪除環(huán)境變量。用 Remove 方法刪除的環(huán)境變量不會被永久刪除;它們只是從當前的會話中刪除。
下面的代碼刪除 Process 環(huán)境變量 TestVar
。
Dim WshShell, WshEnv
Set WshShell = WScript.CreateObject("WScript.Shell")
Set WshEnv = WshShell.Environment("PROCESS")
WshEnv("TestVar") = "Windows Script Host"
WScript.Echo WshShell.ExpandEnvironmentStrings("The value of the test variable is: '%TestVar%'")
WshEnv.Remove
"TestVar"
WScript.Echo WshShell.ExpandEnvironmentStrings("The value of the test variable is: '%TestVar%'")
var WshShell = WScript.CreateObject("WScript.Shell");
var WshEnv = WshShell.Environment("PROCESS");
WshEnv("TestVar") = "Windows Script Host";
WScript.Echo(WshShell.ExpandEnvironmentStrings("The value of the test variable is: '%TestVar%'"));
WshEnv.Remove
("TestVar");
WScript.Echo(WshShell.ExpandEnvironmentStrings("The value of the test variable is: '%TestVar%'"));