cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Use PowerShell to Create a Project and Add a PowerShell Custom Action Using the InstallShield Automation Interface

Use PowerShell to Create a Project and Add a PowerShell Custom Action Using the InstallShield Automation Interface

Summary

The following PowerShell script is an example of how to use InstallShield's Automation Interface to create a project .ism file and then add a PowerShell custom action.

Resolution

# Purpose of this PowerShell script: Create a project .ism file and add a custom action. It may be necessary to change the value of "ISWiAuto26.ISWiProject" depending on the version of InstallShield you are using.

$m_ISWiProj = new-object -comobject ISWiAuto26.ISWiProject

$strFile = "C:\Basic_MSI\Sample\Test.ism"

$m_ISWiProj.CreateProject($strFile,1)

$m_ISWiProj.CloseProject()

$m_ISWiProj.OpenProject($strFile)

$MyCusto = $m_ISWiProj.AddCustomAction("PowerShellCA")

#$MyCusto.ActionType = 1

#MyCusto.ActionType=2097152  // For Immediate Execution
$MyCusto.ActionType=2098176  # For Deferred Execution

$MyCusto.Name = "PowerShellCA"

$MyCusto.SourceEx="C:\Users\Administrator\Desktop\test.ps1"

$MyCusto.Comment = "Test CA PowerShell"

$m_ISWiProj.SaveProject()

$m_ISWiProj.CloseProject()

 

Was this article helpful? Yes No
100% helpful (1/1)
Comments

Very helpful article. I have only one question: I'm currently also trying to add custom actions to my project using PowerShell, and I'm having trouble adding a script that is stored in the binary table, runs as a 64-bit script, and has the execution type "deferred in system context". I assume this is controlled by the ActionType number. Therefore, can you provide a list of the custom InstallShield action types (that also covers my use case)? That would be perfect - thanks.

Version history
Last update:
‎Oct 11, 2021 10:29 AM
Updated by: