以下 VBscript 代码总是无法在本地注册表中找到指定的键,即使它确实存在。我究竟做错了什么?我正在运行 32 位 XP Pro/SP3。
Dim winShell
Set winShell = CreateObject("WScript.Shell")
If regKeyExists(winShell, "HKCU\Software\Microsoft\Windows\CurrentVersion\Run\ProgName\") Then
wscript.echo "ProgName key found"
Else
wscript.echo "Key not found!"
End If
Set winShell = Nothing
Function regKeyExists (winObj, key)
On Error Resume Next
regKeyExists = True
Err.Clear
winObj.RegRead(key)
If Err <> 0 Then regKeyExists = False
Err.Clear
End Function
输出总是显示“找不到密钥!”,即使密钥存在。我难住了!