Engineers Network
  • Home
  • About Us
  • Privacy Policy
  • Contact Us
  • Sitemap
  • Write for us
Home  /  Reviews  /  Two ways of running powershell script from MSI

Two ways of running powershell script from MSI

Tiffany Hurd January 04, 2023 Reviews Leave a Comment

When creating a custom MSI, there are two ways you can run a powershell script right after the installation of an MSI. The first way is by creating your powershell script and placing it under the CustomAction table in MSI. The second method involves creating your text file where you will write out the actual commands that need to be executed.

Table of Contents

Toggle
  • Two ways of running powershell script from MSI
  • Create your powershell script
  • Create CustomAction table in MSI
  • Install the MSI with script
  • Conclusion

Two ways of running powershell script from MSI

There are two ways that you can run a powershell script right after the installation of an MSI. Follow the detailed guide to learn how to execute a powershell script after installing an MSI.

  1. Use the custom action table. This method will allow you to add a command line parameter that tells your script where and when to run. You can specify this in the “Command Line” field of your custom action table, as shown below:
  2. Use the Script Installer. The advantage of using this method is that it will automatically detect any dependencies and apply them before running your main script (the one specified in your main section). For example, if another program is installed at the same time as your PowerShell script, then this method will ensure it gets installed first. The disadvantage is that there isn’t much control over what exactly happens during installation since everything gets bundled into one big package. However, this might not be an issue if all files required by both programs are included within their respective installers anyway!

Create your powershell script

To create a powershell script that can be executed from the MSI, you simply need to save a file with the name of your script in the same folder where your MSI is located. This can be done by right-clicking on a blank space inside the folder, clicking New > Text Document and then renaming it with your desired filename.

Next, you must open up your text document and start writing your script. Make sure that it has the correct file extension (.ps1). This can be done by clicking on the file, going to File > Properties and then clicking on “Change” under the “Open with” section. You will then be able to select your desired program for opening the file.

Create CustomAction table in MSI

The second way to run a PowerShell script from an MSI is by creating a custom action table. The steps are the same as those for writing a VBScript, but with some additional constraints:

  • Add a custom action table in your MSI.
  • Add a Run Command Line action to this table and set its command line parameter to the path of your PowerShell script.
  • Set the condition for this action to call on success only if you want it to run every time the installation runs successfully, or change it if you want it only called when certain conditions are met (for example, when an environment variable meets certain criteria).

Install the MSI with script

You can install the MSI with the script. This is easy to do and requires no extra tools or software. You can just run it from the command line, and you will be provided with all the information you need to make it work.

Run the MSI with a custom action. This involves installing an additional program that will allow you to launch your script within the context of your current application’s interface.

Run the MSI with an installer application, which allows for more control over how your scripts are launched than either of these two methods does by itself.

Conclusion

We have looked at two ways to run a powershell script from MSI. We started by discussing how you can use the built-in feature in Windows to run a script right after the installation of an application. In our second example, we created a custom action table in the MSI file that runs our PowerShell script.

Previous Article
Next Article

About Author

Tiffany Hurd

Related Posts

  • Woman wearing bone conduction headphones while running outdoors.

    How Do Bone Conduction Headphones Work and Are They Worth It?

    June 13, 2026
  • Thousands of digital marketing professionals networking on the busy exhibition floor at DMEXCO 2026 inside Koelnmesse in Cologne, Germany, with branded exhibitor booths lining the halls

    Complete DMEXCO 2026 Guide: Schedule, Venue, Speakers and Networking Tips

    June 11, 2026
  • Aerial view of Lisbon's Parque das Nações district with MEO Arena, venue of Web Summit Lisbon 2026

    Web Summit Lisbon 2026: The Biggest Tech Event of the Year – Dates, Speakers and Insider Secrets

    June 4, 2026

Leave a Reply

Cancel reply

Recent Posts

  • Bose QuietComfort headphones resting on a wooden coffee shop table in New York.
    How to Buy Bose QuietComfort Headphones in New York: Complete Beginner’s Guide June 14, 2026
  • Woman wearing bone conduction headphones while running outdoors.
    How Do Bone Conduction Headphones Work and Are They Worth It? June 13, 2026
  • Thousands of digital marketing professionals networking on the busy exhibition floor at DMEXCO 2026 inside Koelnmesse in Cologne, Germany, with branded exhibitor booths lining the halls
    Complete DMEXCO 2026 Guide: Schedule, Venue, Speakers and Networking Tips June 11, 2026
  • Aerial view of Lisbon's Parque das Nações district with MEO Arena, venue of Web Summit Lisbon 2026
    Web Summit Lisbon 2026: The Biggest Tech Event of the Year – Dates, Speakers and Insider Secrets June 4, 2026

Categories

  • About Engineering
  • Aeronautical Engineering
  • Agricultural Engineering
  • agricultural machinery
  • Architectural Engineering
  • Artificial Intelligence
  • Automotive Engineering
  • Biochemical Engineering
  • Biomedical Engineering
  • Chemical Engineering
  • Civil Engineering
  • Computer Engineering
  • Ecological Engineering
  • Electrical Engineering
  • Engineering Career
  • Environmental Engineering
  • Food Engineering
  • Foreign Article
  • Genetic Engineering
  • Industrial Engineering
  • Mechanical Engineering
  • Medical Engineering
  • Nanotechnology
  • Petroleum Engineering
  • Reviews
  • Solaris Engineering
  • Space Systems Engineering
  • Technology
  • Telecommunication Engineering
  • Types of Engineering

Random Posts

  • Ecological engineering
    Ecological engineering: The interface between science and application in favor of man and biodiversity April 4, 2019
  • Student in California starting a computer engineering career with laptop, coding screen, and circuit board project.
    How to Start a Career in Computer Engineering in California (CA) April 29, 2026
  • 5 Factors to Consider When Choosing a Laptop for College March 11, 2017
  • Best Writing Tablets
    The 6 Best Writing Tablets June 13, 2020

Popular Posts

  • Bose QuietComfort headphones resting on a wooden coffee shop table in New York.
    How to Buy Bose QuietComfort Headphones in New York: Complete Beginner’s Guide June 14, 2026
  • Aims & Objectives December 17, 2015
  • Our Goal December 17, 2015
  • space station
    Russia wants its own space station December 28, 2015
Theme by ThemesPie | Proudly Powered by WordPress