Getting Started with InstallShield Automation and C#

Hi there, it’s me again.  Back this time to cover a more Windows-Centric option: .NET Languages.  In this particular case, I’m working in C# due to this being most familiar to me among the offerings.

To start with, one prerequisite is to add a reference to your project for the InstallShield Automation Library, which is located in the file ISWiAutomation##.dll, where the ## corresponds to the version of InstallShield you’re using.  For example:

C:Program FilesInstallShield2010SystemISWiAutomation16.dll
C:Program FilesInstallShield2011SystemISWiAutomation17.dll

And so on.

Once you’ve got this reference imported, there’s no CreateObject() call like in previous examples, since the CLR will handle this on the back end.

Example 1: Listing Features and Components

This example illustrates iterating through root level features and components.

static void Main(string[] args)
String strOutput = “”;
ISWiAuto17.ISWiProject m_ISWiProj = new ISWiAuto17.ISWiProject();

string strFile = “C:InstallShield 2011 ProjectsMY 64 bit Project.ism”;


foreach (ISWiAuto17.ISWiFeature m_Feature in m_ISWiProj.ISWiFeatures)
strOutput += “Feature: ” + m_Feature.Name + “n”;
strOutput += “Components “;
foreach (ISWiAuto17.ISWiComponent m_Component in m_Feature.ISWiComponents)
strOutput += m_Component.Name + ” “;
strOutput += “n”;



Example 2: Setting Component Properties

This example illustrates getting a specific feature from the ISWiFeatures collection, using it to set component properties, and then saving the project.

static void Main(string[] args)
ISWiAuto17.ISWiFeature m_Feature;

ISWiAuto17.ISWiProject m_ISWiProj = new ISWiAuto17.ISWiProject();

string strFile = “C:InstallShield 2011 ProjectsMY 64 bit Project.ism”;

m_ISWiProj.OpenProject(strFile, false);

m_Feature = m_ISWiProj.ISWiFeatures[“MyApplication”];

foreach (ISWiAuto17.ISWiComponent m_Comp in m_Feature.ISWiComponents)
m_Comp.RemoteInstallation = ISWiAuto17.ISWiRunFromSource.rfsSource;

7 comments on “Getting Started with InstallShield Automation and C#

  1. Cary Roys on   # Reply

    Hi Chris,

    I saw your listing of the ways you came up with to handle this; some I was aware of, and others not.

    Indeed, I know of no other ways to make the code version-independant, as each approach ends up as being hacky, overly time consuming, not type-safe or all of the above.

    I actually wrote up the samples in Java using an Interop library, and it is indeed as you describe – lots of Dispatch.Invoke(), and no type safety.

    All told, my opinion of the lesser of all evils would be .Net 4.0’s Dynamic type and just have it installed on a build server.

  2. TestMe on   # Reply

    HOw to proceed for automation using ISWiAuto20.
    This scomes in Installshield 2013 version.

    Inspite of registering all dlls’ and OCX of installshield, still its fails at:
    ISWiAuto20.ISWiProject m_ISWiProj = new ISWiAuto20.ISWiProject();

    Also I observed that, in 2013 version, ISM file is not created when new project is created using VS 2010.

  3. Sumit Raj on   # Reply

    Set The Platform target to x86. Under Properties->Build of the c# Project.

  4. René on   # Reply

    Same problem here!
    Since IS2013 our .NET Solution isn’t working anymore:
    Unable to cast COM object of type ‘System.__ComObject’ to interface type ‘ISWiAuto20.ISWiProject’. This operation failed because the QueryInterface call on the COM component for the interface with IID ‘{872D23A7-C18D-468C-895D-1CF027E4FBB1}’ failed due to the following error: Library not registered. (Exception from HRESULT: 0x8002801D (TYPE_E_LIBNOTREGISTERED))

  5. ivo on   # Reply

    Hello Cary,
    have you any idea how to reprograming VB to c# or powershell code?
    Especially I would like to know the way, how do I catch build events ( progress … ) using powershell, please.

    Public WithEvents pISWiRelease As ISWiAutoAutomation Interface Version.ISWiRelease
    Private Sub Foo()
    Dim pISWiProject As IswiAutoAutomation Interface Version.ISWiProject
    Set pISWiProject = CreateObject(“IswiAutoAutomation Interface Version.ISWiProject”)
    pISWiProject.OpenProject “C:\InstallShield 2016 Projects\My Project Name-1.ism”, False
    Set pISWiRelease = pISWiProject.ISWiProductConfigs(“Product Configuration 1”).ISWiReleases(“Release 1”)
    Set pISWiRelease = Nothing
    Set pISWiProject = Nothing
    End Sub

    Private Sub pISWiRelease_ProgressIncrement(ByVal lIncrement As Long, pbCancel As Boolean)
    ‘ Place your code here
    End Sub

    Private Sub pISWiRelease_ProgressMax(ByVal lMax As Long, pbCancel As Boolean)
    ‘ Place your code here
    End Sub

    Private Sub pISWiRelease_StatusMessage(ByVal sMessage As String, pbCancel As Boolean)
    ‘ Place your code here
    End Sub

Leave a Reply to René Cancel reply

Your email address will not be published. Required fields are marked *