fbpx
This site uses cookies to offer you a better browsing experience. Find out more on how we use cookies and how you can opt out. Accept
PACE Suite - Application Packaging & Virtualization Software
Request a trial Get a quote Become a partner
Request a demo of PACE Suite now We will get in touch with you right away to schedule a convenient time for your 1-on-1 demo with one of our experts.
I have read and agree to the Privacy Policy
Request a quote Please fill in this quick form and we will send you a free quote shortly.
License *
 Freelancer Enterprise Service Provider
I have read and agree to the Privacy Policy
Request a quote Please fill in this quick form and we will send you a free quote shortly.
License *
 Freelancer Enterprise Service Provider
I have read and agree to the Privacy Policy
Request a call Please fill in this quick form and we will call you back shortly.
I have read and agree to the Privacy Policy
Contact Support Please fill in this quick form to contact our support.
I have read and agree to the Privacy Policy
Subscribe to our Newsletter Be among the first to receive our updates! Fill in this quick form to join the list of subscribers.
Send an email to Tetiana Botanevych Please fill in this quick form to contact our expert directly.
I have read and agree to the Privacy Policy

Run PowerShell script from MSI

“How to run PowerShell script from MSI in PACE Suite?” – that is the question we often recieve during our product demo. Indeed, PowerShell remains a favourite tool of system administrators because they can script alsmost any task with PowerShell (by the way, here is a handy guide on creating and editing scripts from Microsoft). As our PACE Suite helps with all the tasks associated with MSI packaging, today we decided to show how to import PowerShell script to the MSI package in our tool in order to run this script during the installation process.

Our instruction consists of two parts:

  • Importing your PowerShell script to a package
  • Creating a Custom Action to run PowerShell script from MSI

Import PowerShell script to MSI

Launch MSI Editor, a part of PACE Suite, and select Open… from MENU.

run PowerShell script from msi in msi editor

Choose an MSI package, to which you want to import the script, and click Open.

open msi package in msi editor

Open the Files tab.

files tab in msi editor

Select Import files… from the context menu of a folder, to which you want to import the script.

choose where to import script

Click Add -> Select files…

add for choosing scripts

Choose the PowerShell script from your file system and click Open.

choose powershell script to import to msi

Now, either tick the Complete operation with default settings option or go through all the steps, choosing the necessary settings, and complete the Wizard.

msi editor importing scripts wizard

Run PowerShell script from MSI via Custom Action

Open the Custom Actions tab.

custom actions tab in msi editor

Click Add -> Custom action. The Wizard that opens takes into account each option you pick and at further steps, it disables options, which are incompatible with your previous choices, so in the end you get a working Custom Action.

custom actions wizard

Select Launch an EXE and click Next.

choose launch an exe in the wizard

Tick the Located on the system at the path, which is specified in the Command line field, in the selected working folder and click Browse…

choosing settings in the wizard

Select a folder, to which you have imported the PowerShell script and click Select.

choose where powershell script was imported

Enter the powershell.exe -ExecutionPolicy Bypass -File “ to the Command line field, where is a name of your imported PowerShell script with the file extension (e.g. psscript.ps1). Then, click Next.

running powershell script from msi

NOTE -ExecutionPolicy Bypass parameter was added to ensure the Custom Action will always execute regardless of the current execution policy on the system. Select Deferred execution mode, Run in system context and An asynchronous execution that waits for exit code at the end of the sequence options, and click Next.

choose execution mode

Select Run after InstallFiles (or any other position, located below this) from the Execution sequence (recommended) list, if needed, specify execution conditions either by entering them manually or choosing from the drop-down list. Click Finish to add your custom action.

finish to run powershell script via custom action

Click Save from the MENU to save your MSI package.

save changes to msi

That is how easy it is to import and run PowerShell scripts from MSI packages using PACE Suite. Try our MSI authoring tool today to see what else can you do with our smart Wizards and convenient interfaces.

Share this blog article: