Reputation: 11
I'm new to using WixToolset, I'm trying to execute a ps1 file using WixQuietExec - https://wixtoolset.org/docs/v3/customactions/qtexec/. The ps1 script works in general if I execute it directly using powershell. It fails with WixQuietExec
I used the below in my product.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>
I'm able to generate MSI build but when I try to install the MSI, I get the below error logs which doesn't exactly specify the command line error and the MSI installation fails.
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.
Any guidance regarding this issue is truly appreciated. Thank you.
I've read other stackoverflow references Run PowerShell script from WiX installer and other online blogs https://0ptikghost.blogspot.com/2011/03/executing-powershell-scripts-silently.html but nothing works.
Upvotes: 0
Views: 454
Reputation: 11
Using -File
instead of -Command
inside SetProperty
worked for me.
<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>
Not related to this but the powershell process created here is not able to access registry. I've posted a different question for the same Wix Custom Action always creates 32 bit powershell process. How to make it to create a 64 bit process?
Upvotes: 1