我是 WixToolset 的新手,我正在尝试使用 WixQuietExec 执行 ps1 文件 - https://wixtoolset.org/docs/v3/customactions/qtexec/。如果我直接使用 powershell 执行 ps1 脚本,它通常可以正常工作。 WixQuietExec 失败
我在我的产品中使用了以下内容。wxs
<Property Id="POWERSHELLEXE">
<RegistrySearch Id="POWERSHELLEXE"
Type="raw"
Root="HKLM"
Key="SOFTWARE\Microsoft\PowerShell\1\ShellIds\Microsoft.PowerShell"
Name="Path" />
</Property>
<SetProperty Id="SysShell"
Before="SysShell"
Sequence="execute"
Value =""[POWERSHELLEXE]" -NoProfile -NonInteractive -InputFormat None -ExecutionPolicy Bypass -Command "& '[#CreateEventLogPS1]' ; exit $$($Error.Count)"" />
<CustomAction Id="SysShell" BinaryKey="WixCA" DllEntry="WixQuietExec" Execute="deferred" Return="check" Impersonate="no" />
<InstallExecuteSequence>
<Custom Action="SysShell" Before="InstallFinalize">
<![CDATA[NOT Installed]]>
</Custom>
</InstallExecuteSequence>
我能够生成 MSI 版本,但是当我尝试安装 MSI 时,我收到以下错误日志,该日志未准确指定命令行错误,并且 MSI 安装失败。
MSI (s) (E8:C4) [13:41:56:992]: Executing op: ActionStart(Name=SysShell,,)
MSI (s) (E8:C4) [13:41:56:992]: Executing op: CustomActionSchedule(Action=SysShell,ActionType=3073,Source=BinaryData,Target=WixQuietExec,CustomActionData="C:\Windows\SysWOW64\WindowsPowerShell\v1.0\powershell.exe" -NoProfile -NonInteractive -InputFormat None -ExecutionPolicy Bypass -Command "& 'C:\Program Files\UpdateFile\EventLog.ps1' ; exit $($Error.Count)")
MSI (s) (E8:C4) [13:41:57:000]: Creating MSIHANDLE (2) of type 790536 for thread 10436
MSI (s) (E8:50) [13:41:57:000]: Invoking remote custom action. DLL: C:\Windows\Installer\MSIC226.tmp, Entrypoint: WixQuietExec
MSI (s) (E8:1C) [13:41:57:000]: Generating random cookie.
MSI (s) (E8:1C) [13:41:57:017]: Created Custom Action Server with PID 4160 (0x1040).
MSI (s) (E8:C8) [13:41:57:098]: Running as a service.
MSI (s) (E8:C8) [13:41:57:098]: Hello, I'm your 32bit Elevated Non-remapped custom action server.
MSI (s) (E8!E4) [13:42:03:824]: Creating MSIHANDLE (3) of type 790531 for thread 14820
WixQuietExec: Error 0x80070007: Command line returned an error.
MSI (s) (E8!E4) [13:42:03:825]: Closing MSIHANDLE (3) of type 790531 for thread 14820
MSI (s) (E8!E4) [13:42:03:825]: Creating MSIHANDLE (4) of type 790531 for thread 14820
WixQuietExec: Error 0x80070007: QuietExec Failed
MSI (s) (E8!E4) [13:42:03:825]: Closing MSIHANDLE (4) of type 790531 for thread 14820
MSI (s) (E8!E4) [13:42:03:826]: Creating MSIHANDLE (5) of type 790531 for thread 14820
WixQuietExec: Error 0x80070007: Failed in ExecCommon method
MSI (s) (E8!E4) [13:42:03:827]: Closing MSIHANDLE (5) of type 790531 for thread 14820
CustomAction SystemShell returned actual error code 1603 (note this may not be 100% accurate if translation happened inside sandbox)
MSI (s) (E8:50) [13:42:03:828]: Closing MSIHANDLE (2) of type 790536 for thread 10436
Action ended 13:42:03: InstallFinalize. Return value 3.
非常感谢有关此问题的任何指导。谢谢你。
我阅读了其他 stackoverflow 参考资料从 WiX 安装程序运行 PowerShell 脚本和其他在线博客https://0ptikghost.blogspot.com/2011/03/executing-powershell-scripts-silently.html但没有任何效果。
在
-File
中使用 -Command
而不是 SetProperty
对我有用。
<Property Id="POWERSHELLEXE">
<RegistrySearch Id="POWERSHELLEXE"
Type="raw"
Root="HKLM"
Key="SOFTWARE\Microsoft\PowerShell\1\ShellIds\Microsoft.PowerShell"
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>
与此无关,但此处创建的 powershell 进程无法访问注册表。我针对相同的 Wix 自定义操作始终创建 32 位 powershell 进程发布了不同的问题。如何让它创建64位进程?