提问人:im_sam39 提问时间:11/17/2023 更新时间:11/17/2023 访问量:37
Wix 自定义操作始终创建 32 位 powershell 进程。如何创建一个 64 位进程?
Wix Custom Action always creates 32 bit powershell process. How to make it to create a 64 bit process?
问:
我正在使用 WixQuietExec 执行 powershell 脚本。作为 ps1 文件的一部分,我尝试在 HKLM 路径下设置注册表项。
Set-ItemProperty -Path 'HKLM:\Software\Microsoft\Windows\CurrentVersion\Config\Update' -Name Machine -Value "AXBD"
当我使用 Wix 创建 MSI 并安装它时。Set-ItemProperty 始终失败并出现错误'Cannot find path 'HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Config\Update' because it does not exist.'
我已经记录了此 PS1 脚本执行期间的结果,它总是返回 .在 64 位 powershell 进程中,Set-ItemProperty 成功。如何使WIX自定义操作生成64位进程?$([Environment]::Is64BitProcess)
false
我尝试了以下解决方案
附加了 product.wxs 文件中的代码段。我在 RegistrySearch 中包含了 Win64=“yes”。在我包含它之后,MSI 日志将 powershell 路径显示为 .早些时候是.但仍然是执行此 PS1 脚本期间显示的结果。
C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe
C:\Windows\SysWow64\WindowsPowerShell\v1.0\powershell.exe
$([Environment]::Is64BitProcess)
false
此外,我还尝试使用活动解决方案配置作为 64 位平台 - https://stackoverflow.com/a/62130230/22926112 和自定义操作作为 64 位进程创建 WIX 项目构建。
在如何在 WiX 中通过正确访问 Windows 注册表启动 PowerShell?中,提到使用 powershell 的路径进行注册表访问,但该路径在 Windows 10 中不存在。
C:\Windows\sysnative\WindowsPowerShell\v1.0\powershell.exe
MSI 日志
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"
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 =""[POWERSHELLEXE]" -NoProfile -NonInteractive -InputFormat None -ExecutionPolicy Bypass -File "[#CreateEventLogPS1]"" />
<CustomAction Id="SystemShell" BinaryKey="WixCA" DllEntry="WixQuietExec" Execute="deferred" Return="check" Impersonate="no" />
<InstallExecuteSequence>
<Custom Action="SystemShell" Before="InstallFinalize">
<![CDATA[NOT Installed]]>
</Custom>
</InstallExecuteSequence>
答: 暂无答案
评论
Registry