Windows PowerShell to call InstallShield methods

Windows PowerShell to call InstallShield methods
by

Lets Learn Windows PowerShell to call InstallShield methods

I want to share my experiencefrom one of the project that I worked on for integrating TFS 2012 as VCS tool and InstallShield 2013 for creating package (*.msi).

InstallShield directly integrates with Visual Studio, but …. well, the way it was used in this project was a little different.

PowerShell script was used to mimic a CI+CD implementation with TFS as VCS and InstallShield to build and create a MSI package.

Let’s first talk about how we can create and update InstallShield project.

As this is scripted, creating ISM project, updating it with features and components that are changing dynamically is fully automated.

& “\\..\IsCmdBuild.exe”-p” ”*.ism” “-r” “SingleImage” ”-b” ”<\targetfolder>” “-c” “COMP” “–y” “$version” ”-e” ”N” “-a” ”<target filename>”

Assign a variable to the projectfile so that the same can be used for updating the file with different attributes.

$Projectfile = “*.ism”

In Order to update project attributes, the ISM project should be opened,

$project = New-object –com ISWiAuto21.ISWiProject

$Project.OpenProject($Projectfile)

Every project .ism file must have a unique GUID, version, Product Name, Product Code etc.

$project.Productversion=”<version number>”

$project.CompanyName=”<Product Owner Company>”

$project.ProductName=”<name of product>”

$project.GenerateGUID()

$project.PackageCode

$project.ProductCode

A typical product gets installed in ProgramFiles folder in Windows OS. The MSI should be updated with Features and Component information as well.

$adftr = $project.AddFeature(“ProgramFiles”)

In order to add components from a folder that changes dynamically, create a loop to read folder contents and add each as a component to the ISM projectfile.

$var = $project.AddComponent(“<$variable>”)

The Components added to the project should also be attached to the feature for the product installation to succeed.

$adftr.AttachComponent(“<$variable>”)

In order to make sure the component gets added to correct destination, use attribute of the “ÄddComponent” method.

$var.Destination=”[<targetpath>]”

Once all changes are updated, it is important to save and close the project file before the project can be build.

$project.SaveProject()

$project.CloseProject()

There’s definitely lot more methods available for InstallShield updates. One can explore in an open InstallShield project by typing <projectname.*>

Share