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”;
m_ISWiProj.OpenProject(strFile,false);
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”;
}
Console.WriteLine(strOutput);
m_ISWiProj.CloseProject();
}
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;
}
m_ISWiProj.SaveProject();
m_ISWiProj.CloseProject();
}