0

I'm creating an installer with Wix 3.10. This installer will need to execute a PowerShell script after the installation of the files.

To execute the PowerShell script I use the following:

<Component Id="AddUserInstallScript" Guid="{87DB934A-5ECF-4073-81F1-BA139F30A686}" Directory="PHONEMANAGER_FOLDER" >
    <File Id="CreateADUserScript" Name="CreateADUser.ps1" Source="CreateADUser.ps1" KeyPath="yes"/>
</Component>

<Property Id="POWERSHELLEXE" Value="c:\Windows\System32\WindowsPowerShell\v1.0\powershell">
</Property>

<Condition Message="This application requires Windows PowerShell.">
    <![CDATA[Installed OR POWERSHELLEXE]]>
</Condition>

<SetProperty Id="RunPSscriptCommand"
    Before="RunPSscriptCommand"
    Sequence="execute"
    Value="&quot;[POWERSHELLEXE]&quot; -Version 3.0 -NonInteractive -NoLogo -NoProfile -ExecutionPolicy Bypass -Command &quot;&amp;'[#CreateADUserScript]' -domainname '[SERVICE_USER_NETBIOSDOMAIN]' -password '[service_user_pwd]' -domainadminname '[DOMAIN_ADMINISTRATOR]' -domainadminpassword '[domain_administrator_pwd]' ; exit $$($Error.Count)&quot; "
/> 
<CustomAction Id="RunPSscriptCommand" 
            BinaryKey="WixCA" 
            DllEntry="WixQuietExec64"
            Execute="deferred" 
            Return="check" 
            Impersonate="no"/>

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

When I run the installer I'm getting the following error in the log file:

MSI (s) (10:F8) [09:54:54:515]: Invoking remote custom action.
DLL: C:\Windows\Installer\MSI80E7.tmp, Entrypoint: WixQuietExec64
WixQuietExec64: Error 0x80070001: Command line returned an error.
WixQuietExec64: Error 0x80070001: QuietExec64 Failed
WixQuietExec64: Error 0x80070001: Failed in ExecCommon method
CustomAction RunPSscriptCommand returned actual error code 1603
(note this may not be 100% accurate if translation happened inside sandbox)

On the destination machines is PowerShell 3 installed. The script also uses PowerShell 3 modules. I have included the option -InputFormat None but this makes no difference for PowerShell 3.

Any thoughts on this issue?

1 Answer 1

-1
  1. Try to run the script stand alone, in order to exclude command errors.
  2. I have encountered same problem and what solved it was the command length (in your situation is RunPSscriptCommand's value), I have decreased the length to be less than 255 characters.
  3. You can check your powershell version automatically using WixPSExtension.dll

    <PropertyRef Id="POWERSHELLVERSION" />
    <Condition Message="You must have PowerShell 1.0 or higher.">
      <![CDATA[Installed OR POWERSHELLVERSION >= "1.0"]]>
    </Condition>
    

I hope it will help.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.