Note

You are not reading the most recent version of this documentation. See the latest version available.

Run PowerShell script from MSIΒΆ

Run a PowerShell script from MSI.

Video manual:


Important

Precondition: Open an MSI package in MSI Editor (see Open MSI/MST).

  1. First, import the PowerShell script that you need to run to MSI.
    1. Go to the Package Designer > Files and folders tab.

      image390

    2. Select Import files from the context menu where you want to import the PowerShell script.

      image391

    3. Click Add > Add files to choose the script.

      image392

    4. Choose your PowerShell script and click Open.

      image393

    5. Tick the Complete operation with default settings option and click Finish.

      image394

  2. Add custom action to run the PowerShell script.
    1. Go to the Package Designer > Custom actions tab.

      image395

    2. Select Add > Custom action from the toolbox.

      image396

    3. Select Launch an EXE and click Next.

      image397

    4. Select the Located on the system at the path, which is specified in the Command line field, in the selected working folder option and click Browse.

      image398

    5. Select a folder that contains the PowerShell script you have imported and then, click Select.

      image399

    6. Enter the powershell.exe -ExecutionPolicy Bypass -File "<script file name>.ps1" to Command line, where <script file name> is replaced with a name of your PowerShell script (e.g. psscript.ps1). Then, click Next.

      image400

      Note

      -ExecutionPolicy Bypass parameter is added to make sure that the custom action will always execute regardless of the current execution policy on the system.

    7. Select the Deferred execution mode, and the Run in system context option. From the Return processing options list, choose An asynchronous execution that waits for exit code at the end of the sequence, and click Next.

      image401

    8. From the Execution sequence (recommended) list, select Run after InstallFiles (or any other position located below). If needed, specify the execution conditions - enter them manually or choose from the dropped list. Then, click Finish.

      image402




Note

PACE Suite covers the whole range of application packaging tasks - learn more.

Try PACE Suite for free - 30 days no obligations unlimited trial with all functions unlocked.