Sign in to follow this  
Followers 0
ModemJunki

Reading run key under Win 7 x64

5 posts in this topic

I need to get the contents of a key in Windows 7 64-bit.

But I end up with an errorlevel of -1 with code below.

What am I doing wrong?

$var1 = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run", "nwiz")
$var2 = @error

If Not $var2 = 0 then MsgBox(4096, "Error", "Errorlevel is " & $var2)
If $var2 = 0 then MsgBox(4096, "Value is ", $var1)

Share this post


Link to post
Share on other sites



@error -1 means "unable to open requested value"...Are you sure that there is a "nwiz" value in the registry key?

Also, I would just use "If $var2 <> 0"

Share this post


Link to post
Share on other sites

@error -1 means "unable to open requested value"...Are you sure that there is a "nwiz" value in the registry key?

Also, I would just use "If $var2 <> 0"

Yep, the key value is there in regedit. This could be a WoW3264 thing, now that I think about it, where the 64 bit OS is somehow redirecting the registry reads.

I'm not a programmer, so I dunno.

Sloppy if not/if is result of me doing a WTF when this didn't work, the actual code would read string and compare to another variable then change it only if needed.

Share this post


Link to post
Share on other sites

You are correct about that..this shows what values are in the the key

$Count = 1
While 1
    $Val = RegEnumVal("HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Run", $Count)
    If @error = -1 Then ExitLoop
    MsgBox(4096, "Value is ", $val)
    $Count +=1
WEnd
Perhaps you can scroll through this list and check for your Value name. Incidentally, regedit shows "BCSSync" as the only value in my HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Run, but it does not show up in this list. I even tried regedt32 with the same results

Share this post


Link to post
Share on other sites

You are correct about that..this shows what values are in the the key

$Count = 1
While 1
    $Val = RegEnumVal("HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Run", $Count)
    If @error = -1 Then ExitLoop
    MsgBox(4096, "Value is ", $val)
    $Count +=1
WEnd
Perhaps you can scroll through this list and check for your Value name. Incidentally, regedit shows "BCSSync" as the only value in my HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Run, but it does not show up in this list. I even tried regedt32 with the same results

Thanks. I fired up an XP 32-bit box to do some experimenting and my original code snippet works there without problem.

I have the same result with your code - there are other values in the key, but not the ones I see in regedit. The values being shown are in key HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Run.

Even RegistryWorkshop reads the key like it was a normal key.

I'm stumped.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0