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

Registry
plus

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

Importing 64 bit Registry Settings

 Keywords: WinBatch Registry Function 32 64 x32 x64 bit Windows Reg RegEdit Import IntControl 92

Question:

I'm trying to import a registry file on 64-bit windows to modify keys under HKEY_LOCAL_MACHINE\Software. So far all attempts from WinBatch modify HKEY_LOCAL_MACHINE\Software\WOW6432Node. I tried calling RegOpenFlags(64) before using RunShell to launch "RegEdit /s"--no luck. I also tried launching cmd.exe /c and passing regedit as a command line--it still modifies the WOW6432Node. What has me perplexed is that if I open a cmd window and type the regedit command I get the effect I desire.

Does anyone have any insight into this? I'm almost at the point where I import the file to the wrong key and then copy the result over to the "correct" branch. Painful but I think that would work.

Answer:

RegOpenFlags(64) only affects the WinBatch process. It does not (nor cannot) affect other processes started by WinBatch.

On the other hand, because WinBatch is a 32-bit process, it has 32-bit file redirection enabled. So when you perform a RunShell, the 32-bit version of cmd.exe or regedit.exe is started. Since they are 32-bit apps, they default to the 32-bit view of the registry.

To modify a the 64-bit registry with regedit.exe or cmd.exe you need to start the 64-bit version of these apps. To do this call InControl 92. For example

   Oldvalue = IntControl( 92, "disable", 0, 0, 0 )
   RunShell( DirWindows(0):"regedit.exe" , "blahblahblah", DirScript(), @NORMAL, @NOWAIT )
   IntControl( 92, "revert", Oldvalue, 0, 0 )

It is very important that you call the 'revert' INT92 immediately after the RunShell.


Article ID:   W18229
Filename:   Importing 64 bit Registry Settings.txt
File Created: 2009:09:30:11:01:50
Last Updated: 2009:09:30:11:01:50