从注册表中删除项及其某个值。
object.RegDelete(strName)
通过用最后的反斜线终止 strName 来指定项名;停止它后指定值名。完全限定的项名和值名的前缀为根项。可以将缩写版本的根项名称用于 RegDelete 方法。下表中列出您可能用到的五个根项。
根项名 | 缩写 |
---|---|
HKEY_CURRENT_USER | HKCU |
HKEY_LOCAL_MACHINE | HKLM |
HKEY_CLASSES_ROOT | HKCR |
HKEY_USERS | HKEY_USERS |
HKEY_CURRENT_CONFIG | HKEY_CURRENT_CONFIG |
下面的代码创建一个项和两个值,读取它们,然后删除它们。
Dim WshShell, bKey Set WshShell = WScript.CreateObject("WScript.Shell") WshShell.RegWrite "HKCU\Software\ACME\FortuneTeller\", 1, "REG_BINARY" WshShell.RegWrite "HKCU\Software\ACME\FortuneTeller\MindReader", "Goocher!", "REG_SZ" bKey = WshShell.RegRead("HKCU\Software\ACME\FortuneTeller\") WScript.Echo WshShell.RegRead("HKCU\Software\ACME\FortuneTeller\MindReader") WshShell.RegDelete
"HKCU\Software\ACME\FortuneTeller\MindReader" WshShell.RegDelete
"HKCU\Software\ACME\FortuneTeller\" WshShell.RegDelete
"HKCU\Software\ACME\"
var WshShell = WScript.CreateObject("WScript.Shell"); WshShell.RegWrite ("HKCU\\Software\\ACME\\FortuneTeller\\", 1, "REG_BINARY"); WshShell.RegWrite ("HKCU\\Software\\ACME\\FortuneTeller\\MindReader", "Goocher!", "REG_SZ"); var bKey = WshShell.RegRead ("HKCU\\Software\\ACME\\FortuneTeller\\"); WScript.Echo (WshShell.RegRead ("HKCU\\Software\\ACME\\FortuneTeller\\MindReader")); WshShell.RegDelete
("HKCU\\Software\\ACME\\FortuneTeller\\MindReader"); WshShell.RegDelete
("HKCU\\Software\\ACME\\FortuneTeller\\"); WshShell.RegDelete
("HKCU\\Software\\ACME\\");