Jump to content

Can't RegRead() for Vista64 Business?


rudi
 Share

Recommended Posts

Hi.

To upgrade the Vista Client I need to first uninstall older versions. The according uninstallstring is stored in the typical location in the Registry.

The command line works fine with Vista 64bit:

reg query "hklm\software\microsoft\windows\currentversion\uninstall\Novell Client for Windows" /v "uninstallstring"

Output for Vista64:

! REG.EXE VERSION 3.0

HKEY_LOCAL_MACHINE\software\microsoft\windows\currentversion\uninstall\Novell Client for Windows
    uninstallstring  REG_EXPAND_SZ   %SystemRoot%\system32\rundll32 nwsetup.dll NWUninstallClient#Region

This script works fine for XP, but not for Vista64:

$Key="hklm\software\microsoft\windows\currentversion\uninstall\Novell Client for Windows"
$Val="uninstallstring" 

$UIString=RegRead($Key,$Val)
MsgBox(0,@error,$UIString)

@Error is "1" when started at a Vista64 PC (That's fact for other Values as well, no matter what key/val I want to read for Vista64)

What do I miss?

Regards, Rudi.

Earth is flat, pigs can fly, and Nuclear Power is SAFE!

Link to comment
Share on other sites

Place:

#RequireAdmin

.. at the top of your script.

Vista requires admin rights to work with the registry.

My Projects: [topic="89413"]GoogleHack Search[/topic], [topic="67095"]Swiss File Knife GUI[/topic], [topic="69072"]Mouse Location Pointer[/topic], [topic="86040"]Standard Deviation Calculator[/topic]

Link to comment
Share on other sites

Place:

#RequireAdmin

.. at the top of your script.

Vista requires admin rights to work with the registry.

Doesn't help either:

#RequireAdmin

$Key="hklm\software\microsoft\windows\currentversion\uninstall\Novell Client for Windows"
$Val="uninstallstring" 

$UIString=RegRead($Key,$Val)
MsgBox(0,@error,$UIString)

The user I'm logged on is "Administrator"...

So you say it *should* do?

Regards, Rudi.

Earth is flat, pigs can fly, and Nuclear Power is SAFE!

Link to comment
Share on other sites

I figured you were planning on doing something with the registry after determining if the value was there. If you aren't planning on writing to the registry later on then you don't need the authorization at the top of your script.

$Key = "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion"
$Val = "ProgramFilesDir"
;$Key="hklm\software\microsoft\windows\currentversion\uninstall\Novell Client for Windows"
;$Val="uninstallstring" 

$UIString=RegRead($Key,$Val)
MsgBox(0,@error,$UIString)

test that and see if it returns 0 and the correct parameter to see if you at least get a proper return in vista 64.

Edited by Ealric

My Projects: [topic="89413"]GoogleHack Search[/topic], [topic="67095"]Swiss File Knife GUI[/topic], [topic="69072"]Mouse Location Pointer[/topic], [topic="86040"]Standard Deviation Calculator[/topic]

Link to comment
Share on other sites

Hi.

It's NOT the #RequireAdmin.

Help File: "When running on 64-bit Windows if you want to read a value specific to the 64-bit environment you have to suffix the HK... with 64 i.e. HKLM64."

How to know, that a vlaue is "specific to the 64-bit environment"? That's propably all but "32-bit" values? Those might be found in WOW6432Node?

$UISTring=RegRead("hklm64\software\microsoft\windows\currentversion\uninstall\novell client for windows","uninstallstring")

is working fine.

Regards, Rudi.

Earth is flat, pigs can fly, and Nuclear Power is SAFE!

Link to comment
Share on other sites

Hi.

It's NOT the #RequireAdmin.

Help File: "When running on 64-bit Windows if you want to read a value specific to the 64-bit environment you have to suffix the HK... with 64 i.e. HKLM64."

How to know, that a vlaue is "specific to the 64-bit environment"? That's propably all but "32-bit" values? Those might be found in WOW6432Node?

$UISTring=RegRead("hklm64\software\microsoft\windows\currentversion\uninstall\novell client for windows","uninstallstring")

is working fine.

Regards, Rudi.

Good to know. I haven't had to read the registry with my vista-64 bit computer but I just tested it and you posted right as I was about to. :0 Good job finding out the issue on your own.

WOW6432Node - The OS uses this key to present a separate view of HKEY_LOCAL_MACHINE\SOFTWARE for 32-bit applications that run on a 64-bit version of Windows. When a 32-bit application queries a value under the HKEY_LOCAL_MACHINE\SOFTWARE\<company>\<product> subkey, the application reads from the HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\<company>\<product> subkey.

Edited by Ealric

My Projects: [topic="89413"]GoogleHack Search[/topic], [topic="67095"]Swiss File Knife GUI[/topic], [topic="69072"]Mouse Location Pointer[/topic], [topic="86040"]Standard Deviation Calculator[/topic]

Link to comment
Share on other sites

I'm sorry, but everything above is irrelevant (had the same problem some time ago).

On x64, the registry and some parts of the filesystem are "virtualized" to keep compatibility with 32bit programs. Regarding the filesystem this is the reason for the "C:\WINDOWS\SysWOW64" directory to exist.

So if on an x64 system you try to access the key [HKEY_LOCAL_MACHINE\SOFTWARE\microsoft\windows\currentversion\uninstall\Novell Client for Windows] with an x32 executable, its access gets redirected to the [HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Bla]

There of course your keys won't exist. Try to compile the tool with CTRL+F7 to an x64 executable and check if it works then...

My general workaround is to do all the registry access by a "sub-executable" which I have ready in both x32 and x64 versions and ressource them into the "main-executable" from which they are called depending on the @OSArch macro.

Regards,

Chris

EDIT: I seem to have typed lengths to slow to be helpful :) I see you found the solution yourself...grats!

Edited by cherdeg
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...