Writing to 64-bit registry from 32-bit installer
Asked Answered
D

6

6

I have a 32-bit application and a 32-bit installer, written in Wise Installation Studio. I know...I shouldn't be using Wise and I should switch to something else. But for now, I'm stuck with it.

Our application is graphics-intensive and to improve performance, we want it to disable desktop composition (Windows Aero) while running. We accomplished this on 32-bit systems by adding a registry entry at:

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers

with a value of DISABLEDWM.

This sets the "Disable desktop composition" checkbox in the compatibility tab of the properties for our EXE to be checked by default.

This works perfectly on 32-bit systems, but when running the installer on a 64-bit system, Windows redirects the creation of registry entries to HKLM\SOFTWARE\Wow6432Node, and the flag is not set correctly. If I manually create an entry in the 64-bit registry view, then it works.

So how can I force this registry key to be created in the 64-bit registry view from our 32-bit installer? Or is there a better way to set this property aside from creating a registry entry?

Dropper answered 19/3, 2012 at 15:1 Comment(2)
Is that Wise project type an MSI installer?Bodiless
@ChristopherPainter: I don't think so (not sure how to check). But the resulting installer has a .exe extension (not .msi). Any idea where to look for that in Wise Installation Studio?Dropper
S
5

I'm not sure what possibilities Wise gives you regarding scripting, but the way to access the 64-bit registry from a regular program is to use KEY_WOW64_64KEY when manipulating the registry.

If it's a possibility to at the least run an external EXE file from the setup, it should solve your problem.

Showily answered 19/3, 2012 at 15:8 Comment(1)
Thanks. Looks like this is what we will have to do, at least until I can convince everyone else that it's worth it to spend some extra time migrating to a new installer.Dropper
P
4

I am not sure if this solution was possible at the time this question was asked, but you can create a custom action that executes a REG ADD command and include the /reg:64 switch, like this:

REG ADD "HKLM\Software\Example" /v "Name" /t REG_SZ /d "Data" /reg:64

The /reg:64 switch will force it to the 64-bit registry. I am not entirely sure what this will do on a 32-bit system, but I expect it will probably be ignored.

Photolithography answered 4/5, 2016 at 10:39 Comment(2)
This is actually the proper way to do it. The accepted answer is valid for API calls but in this case, when using REG to add/delete a key the /reg:64 will do the trick.Basia
it works on a 32 bit OS too and just goes to the regular 32 bit registry if you specify /reg:64Attaboy
O
0

Usually you can not access the 64 bit registry from 32 bit applications. I have found some code, which is for PowerShell, that allows you to access the 64 bit registry through WMI: http://gallery.technet.microsoft.com/scriptcenter/6062bbfc-53bf-4f92-994d-08f18c8324c0

However, I'm not sure whether you can use this in Wise. You could use Windows Installer XML instead and have it create a 64-bit MSI.

Overword answered 19/3, 2012 at 15:9 Comment(0)
E
0

I also use Wise and have to support both 32 and 64 bit windows. I have had some success using batch files to call reg.exe to delete and query 64 bit registry entries. You should be able to employ the same technique to add and modify the registry. I look for "program files(x86) to determine if it is 64 bit windows. If not, I use the native registry controls in wise, otherwise, I use the batch files with passed in parameters. Reg.exe should be in your path. go to a dos prompt and type reg /? to get the syntax.

I have a regtest.bat, which contains the following: reg.exe query %1 /v %2 > %3

The first param is the registry key, second is the value, and third is the text file it is written to.

My regdelete.bat contains: reg.exe delete %1 /f The param is the registry entry you want to delete.

Endsley answered 20/6, 2013 at 13:49 Comment(0)
P
0

The problem still exists although query registry with Reg.exe Because when the bat file called by Wise, the reg query can not find 64 bit key(only 32 bit key can be found).

Panicle answered 15/8, 2013 at 5:41 Comment(0)
A
0

You could also use

c:\Windows\SysNative\REG.exe ADD "HKLM\Software\Example" /v "Name" /t REG_SZ /d "Data"

This forces the use of the 64-bit version of reg.exe. Of course, that's not going to work if you're on a 32-bit OS. So you should put in a check for the OS type, and then call the proper reg.exe program (either c:\Windows\System32 for 32-bit OS, or C:\Windows\SysNative for 64-bit OS).

The environment variable PROCESSOR_ARCHITEW6432 will have the value of AMD64 if it's a 64-bit OS, and empty if 32-bit OS.

Antique answered 23/8, 2018 at 0:40 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.