Hi All,
I'm using this bit of code to check if a registry value exists,
set wshShell= Wscript.CreateObject("WScript.Shell")
strKey= "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\"
present = WshShell.RegRead(strKey)
MsgBox strKey
But it keeps returning the message
"Unable to open registry key "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\" for reading.
Now this is dumb, because I can see the key in the registry!!
So I tried another approach with this script.
set wshShell=Wscript.CreateObject("WScript.Shell")
strKey="HKLM\SOFTWARE\Microsoft\"
If RegKeyExists(strKey) = True Then
wscript.echo "key present"
Else
wscript.echo "key not present"
End If
Function RegKeyExists(strKey)
Dim strkeytotest
RegKeyExists = True
On Error Resume Next
strkeytotest = wshShell.RegRead(strKey)
If Err <> 0 Then
RegKeyExists = False
End If
End Function
However this dosen't work either, because it just keeps returning "Key not present", which again is dumb since the key for Microsoft is very much present.
I'm stuck and can't figure out why this ain't working. Any help would be greatly appreciated.
Cheers in advance.
I'm using this bit of code to check if a registry value exists,
set wshShell= Wscript.CreateObject("WScript.Shell")
strKey= "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\"
present = WshShell.RegRead(strKey)
MsgBox strKey
But it keeps returning the message
"Unable to open registry key "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\" for reading.
Now this is dumb, because I can see the key in the registry!!
So I tried another approach with this script.
set wshShell=Wscript.CreateObject("WScript.Shell")
strKey="HKLM\SOFTWARE\Microsoft\"
If RegKeyExists(strKey) = True Then
wscript.echo "key present"
Else
wscript.echo "key not present"
End If
Function RegKeyExists(strKey)
Dim strkeytotest
RegKeyExists = True
On Error Resume Next
strkeytotest = wshShell.RegRead(strKey)
If Err <> 0 Then
RegKeyExists = False
End If
End Function
However this dosen't work either, because it just keeps returning "Key not present", which again is dumb since the key for Microsoft is very much present.
I'm stuck and can't figure out why this ain't working. Any help would be greatly appreciated.
Cheers in advance.