Wix Custom Action always creates 32 bit powershell process. How to make it to create a 64 bit process?

94 views Asked by At

I'm executing a powershell script using WixQuietExec. As a part of the ps1 file, I'm trying to set a registry key under the HKLM path.

 Set-ItemProperty -Path 'HKLM:\Software\Microsoft\Windows\CurrentVersion\Config\Update' -Name Machine -Value "AXBD"

When I create the MSI using Wix and install it. Set-ItemProperty always fails with error 'Cannot find path 'HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Config\Update' because it does not exist.'

I've logged the result of $([Environment]::Is64BitProcess) during the execution of this PS1 script and it always returns false. In a 64 bit powershell process, Set-ItemProperty succeeds. How to make WIX Custom Action generate a 64 bit process?

I've tried the following solutions

  1. Attached the snippet from product.wxs file. I included Win64="yes" in RegistrySearch. After I included it, MSI logs show powershell path as C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe. Earlier it was C:\Windows\SysWow64\WindowsPowerShell\v1.0\powershell.exe. But still the result of $([Environment]::Is64BitProcess) shows false during the execution of this PS1 script.

  2. Also, I've tried creating the WIX project build using the active solution configuration as 64 bit platform - https://stackoverflow.com/a/62130230/22926112 & Custom action as 64 bit process.

  3. In How to start PowerShell in WiX with proper access to Windows Registry?, it is mentioned to use C:\Windows\sysnative\WindowsPowerShell\v1.0\powershell.exe path of powershell for registry access, but the path is not present in windows 10.

MSI Logs

MSI (s) (88:CC) [17:59:30:705]: Created Custom Action Server with PID 21744 (0x54F0).
MSI (s) (88:50) [17:59:30:785]: Running as a service.
MSI (s) (88:50) [17:59:30:793]: Hello, I'm your 32bit Elevated Non-remapped custom action server.
MSI (s) (88:7C) [17:59:34:206]: Closing MSIHANDLE (3) of type 790536 for thread 18548
MSI (s) (88:74) [17:59:34:207]: Executing op: End(Checksum=0,ProgressTotalHDWord=0,ProgressTotalLDWord=138793680)
MSI (s) (88:74) [17:59:34:217]: Note: 1: 2265 2:  3: -2147287035 
MSI (s) (88:74) [17:59:34:217]: User policy value 'DisableRollback' is 0
MSI (s) (88:74) [17:59:34:217]: Machine policy value 'DisableRollback' is 0
MSI (s) (88:74) [17:59:34:217]: Note: 1: 2265 2:  3: -2147287035 
MSI (s) (88:74) [17:59:34:225]: Note: 1: 2318 2:  
MSI (s) (88:74) [17:59:34:225]: Note: 1: 2318 2:  
MSI (s) (88:74) [17:59:34:233]: No System Restore sequence number for this installation.
MSI (s) (88:74) [17:59:34:233]: Unlocking Server
MSI (s) (88:74) [17:59:34:233]: PROPERTY CHANGE: Deleting UpdateStarted property. Its current value is '1'.
Action ended 17:59:34: InstallFinalize. Return value 1.
Action ended 17:59:34: INSTALL. Return value 1.
Property(S): UpgradeCode = {9D1553C7-1256-4F30-B863-745E0B3C2555}
Property(S): POWERSHELLEXE = C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe
Property(S): INSTALLFOLDER = C:\Program Files\UpdateA\
Property(S): dir8285H1CB2B21A8DD93795FD0ECB81D93 = C:\Program Files\UpdateA\pki\
Property(S): SystemShell = "C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe" -NoProfile -NonInteractive -InputFormat None -ExecutionPolicy Bypass -File "C:\Program Files\UpdateA\Create-EventLog.ps1"

Snippet from Product.wxs

        <Property Id="POWERSHELLEXE">
            <RegistrySearch Id="POWERSHELLEXE"
                            Type="raw"
                            Root="HKLM"
                            Key="SOFTWARE\Microsoft\PowerShell\1\ShellIds\Microsoft.PowerShell"
                            Win64="yes"
                            Name="Path" />
        </Property>
        <Condition Message="This application requires Windows PowerShell.">
            <![CDATA[Installed OR POWERSHELLEXE]]>
        </Condition>

        <SetProperty Id="SystemShell"
                Before="SystemShell"
                Sequence="execute"
                Value ="&quot;[POWERSHELLEXE]&quot; -NoProfile -NonInteractive -InputFormat None -ExecutionPolicy Bypass -File &quot;[#CreateEventLogPS1]&quot;" />

        <CustomAction Id="SystemShell" BinaryKey="WixCA" DllEntry="WixQuietExec" Execute="deferred" Return="check" Impersonate="no" />

        <InstallExecuteSequence>
            <Custom Action="SystemShell" Before="InstallFinalize">
                <![CDATA[NOT Installed]]>
            </Custom>
        </InstallExecuteSequence>
0

There are 0 answers