检查注册表项是否存在无效

时间:2015-09-16 11:52:43

标签: vbscript

我正在尝试读取一个注册表项并查看它是否存在 - 我已经完成了以下操作但我继续得到错误,该键不存在...什么时候出现?我做错了什么?

[Const HKEY_LOCAL_MACHINE = &H80000002

strComputer = "."
Set objRegistry = GetObject("winmgmts:\\" & _ 
    strComputer & "\root\default:StdRegProv")

strKeyPath = "SOFTWARE\Microsoft\Windows\CurrentVersion\Internet Settings\ZoneMap\EscDomains\localhost"
strValueName = "http"
objRegistry.GetStringValue HKEY_LOCAL_MACHINE,strKeyPath,strValueName,strValue

If IsNull(strValue) Then
    Wscript.Echo "The registry key does not exist."
Else
    Wscript.Echo "The registry key exists."
End If

enter image description here

1 个答案:

答案 0 :(得分:0)

我的错...我正在寻找注册表的值,而不是实际的keyName ..将其改为“strValueName”:

If IsNull(**strValueName**) Then
    Wscript.Echo "The registry key does not exist."
Else
    Wscript.Echo "The registry key exists."
End If

现在工作正常..

相关问题