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
No ratings
Version history
Revision #:
10 of 10
Last update:
‎Oct 11, 2021 10:29 AM
Updated by: