Wix - install and then run a powershell script Wix - install and then run a powershell script powershell powershell

Wix - install and then run a powershell script


you obviously got this example from the same site as me... you found one of the errors, but not the other one :-)

In your SetProperty Id="RunPScript" node, you need to change the [POWERSHELL.EXE] TO [POWERSHELLEXE] as per how it is defined in the property above where you retrieve the path from the registry.


Try changing when the SetProperty is executed.

It looks like the SetProperty element is called After 'InstallFiles' and the Custom action is also set to run After 'InstallFiles'. You could try change the SetProperty element to execute Before 'InstallFiles', somethink like this:

<SetProperty Id="RunPSscript"     Before="InstallFiles"     Sequence="execute"     Value =""[POWERSHELL.EXE]" -Version 2.0 -NoProfile -NonInteractive -InputFormat None -ExecutionPolicy Bypass -Command "& '[#C2WTS_service_install.ps1]' ; exit $$($Error.Count)"" />

The rest looks alright although I normally have the custom action wrapped in a InstallExecuteSequence element.

<InstallExecuteSequence>    <Custom Action="RunPSscript" After="InstallFiles"><![CDATA[NOT Installed]]>/Custom></InstallExecuteSequence>