I am trying to read a registry key value on Win7 64bit system and one time it will work and the next it won't. Driving me mad!

The key exists and has a value. The permissions say it should be readable.
About as simple a read as you can do in a vb script

Dim thing
thing = "HKEY_LOCAL_MACHINE\SOFTWARE\Intel\WirelessCommon\AppFramework\Settings\PROSetVersion"
sRegVer = oShell.RegRead(thing)
WScript.Echo sRegVer

Error is "Invalid Root in Registry Key"
which is usually a permissions thing provided your reg path and key are correct.
I have tested this on multiple systems with the same result.

if it never worked, then I know it is my fault, but if it sometimes works?!

Anybody run into intermittent read problems like this?
0 Comments   [ + ] Show Comments

Comments

Please log in to comment

Rating comments in this legacy AppDeploy message board thread won't reorder them,
so that the conversation will remain readable.

Answers

0
ProcMon will show you what's going on. It will display a NAME NOT FOUND or ACCESS DENIED error at the first key that RegRead fails on.
Answered 05/15/2010 by: VBScab
Red Belt

Please log in to comment
0
Try this:
Option Explicit
Dim oShell, thing, sRegVer
Set oShell = WScript.CreateObject("WScript.Shell")
thing = "HKEY_LOCAL_MACHINE\SOFTWARE\Intel\WirelessCommon\AppFramework\Settings\PROSetVersion"
sRegVer = oShell.RegRead(thing)
WScript.Echo sRegVer

If that doesn't work, you might try VBScab's method, or else look into using the StdRegProv Class: http://msdn.microsoft.com/en-us/library/aa393664(VS.85).aspx
Answered 05/16/2010 by: Lucid
Purple Belt

Please log in to comment
0
I don't think that a missing Shell object is the problem. If it was, the RegRead would fail with an 'Object required' error.
Answered 05/17/2010 by: VBScab
Red Belt

Please log in to comment
Answer this question or Comment on this question for clarity