Search code examples
powershellwindows-installer

How can a create a simple MSI running a simple ps1 script with parameters?


I want to package my ps1 script into an MSI

the ps1 name apple.ps1, which will input 2 parameters

./apple.ps1 <param1> <param2>

How can i make an msi package to run the apple.ps1?

and in that msi package, there is an option to let me input two parameter

Is there any tutorial or easy way to do it?


Solution

  • You can call a PowerShell script with a custom action. Here is an example how to do it with Wix:

    http://damienbod.wordpress.com/2013/09/01/wix-installer-with-powershell-scripts/

    Command line parameters are automatically gathered in syntax form NAME=VALUE at the end of the command line. See msiexec.exe /h for examples.

    Using property values depends on the tool you are using to make the MSI.Here is an article that might help showing how to use them in Visual Studio's installer editor.

    http://www.codeproject.com/Articles/16767/How-to-Pass-Command-Line-Arguments-to-MSI-Installe