WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

64-bit

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

Registry Redirection

 Keywords:  

Question:

I'm seeing 2 different results in Vista/64 for what looks like the same string. In using regedit it seems the answer to both should be c:\program files (x86) But one the first line below shows just c:\program files. and no (x86) Am I looking at this wrong & thanks!
b=RegQueryValue(@REGMACHINE, "SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion[ProgramFilesDir]")
Message("ProgramFiles", b)

b=RegQueryValue(@REGMACHINE, "SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion[ProgramFilesDir (x86)]")
Message("ProgramFiles (x86)", b)
Exit

Answer:

Its call registry redirection and you have fallen victim to it.

Basically, all x86-64 based Windows operation systems maintain two views of the registry - a 32-bit view and a 64-bit view. By default WinBatch uses the 64-bit view. You can switch between views using the RegOpenFlags function (see the help file for details.)

The reason you are getting your results is that you are looking at the registry from the 64-bit view and the Wow6432Node part of the path is basically ignored by the underlying Windows API registry functions. So you are actually getting the values in

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion
instead.

The first rule of using registry functions on 64-bit windows is to NEVER use 'Wow6432Node' as part of a subkey name. Instead switch to the 32-bit view and use the subkey name without the 'Wow6432Node'.

User Reply:

Fast & Excellent reply - I've got it working now.
Article ID:   W17648
Filename:   Registry Redirection.txt
File Created: 2010:01:11:12:02:52
Last Updated: 2010:01:11:12:02:52