I found several examples showing how to run a PowerShell script from WiX, but none of them could be launched. So, I would like to publish what I have, with the hope that someone can indicate what I am doing wrong.
<DirectoryRef Id="INSTALLFOLDER"> <Component Id="cmp_ShutdownIExplore" Guid="{4AFAACBC-97BB-416f-9946-68E2A795EA20}" KeyPath="yes"> <File Id="ShutdownIExplore" Name="ShutdownIExplore.ps1" Source="$(var.ProjectDir)Source\PowerShell\ShutdownIExplore.ps1" Vital="yes" /> </Component> </DirectoryRef> <CustomAction Id="RunPowerShellScript" BinaryKey="WixCA" DllEntry="CAQuietExec" Execute="deferred" Return="check" Impersonate="yes" /> <InstallExecuteSequence> <Custom Action="RunPowerShellScript" After="InstallFiles"><![CDATA[NOT Installed]]></Custom> </InstallExecuteSequence> <Fragment> <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="RunPowerShellScript" Before ="InstallFiles" Sequence="execute" Value =""[POWERSHELLEXE]" -Version 2.0 -NoProfile -NonInteractive -InputFormat None -ExecutionPolicy Bypass -Command "& '[#ShutdownIExplore.ps1]' ; exit $$($Error.Count)"" /> </Fragment>
When I run the installer that I created, I get the following error (from the log):
MSI (s) (DC:F8) [11:21:46:424]: Executing op: ActionStart(Name=RunPowerShellScript,,) Action 11:21:46: RunPowerShellScript. MSI (s) (DC:F8) [11:21:46:425]: Executing op: CustomActionSchedule(Action=RunPowerShellScript,ActionType=1025,Source=BinaryData,Target=CAQuietExec,) MSI (s) (DC:9C) [11:21:46:459]: Invoking remote custom action. DLL: C:\Windows\Installer\MSI8228.tmp, Entrypoint: CAQuietExec CAQuietExec: Error 0x80070057: failed to get command line data CAQuietExec: Error 0x80070057: failed to get Command Line CustomAction RunPowerShellScript returned actual error code 1603 (note this may not be 100% accurate if translation happened inside sandbox) Action ended 11:21:46: InstallFinalize. Return value 3.
I do not quite understand what this error is trying to say. Are my internal recommendations bad? Is the command to execute the script bad? Something else?
Any help is greatly appreciated and thanks in advance.
source share