Running Project Reports Using the Automation Interface
InstallShield 2024
This VBScript example below accesses objects in a setup project to display a report of the total number of features, components, files, and various types of files. The output is displayed in a message box, but you could also write this information to a text file.
Requirements
The following requirements should be met:
• | You must have Windows Scripting Host to run a .vbs file. (It would be very simple to modify this script to run in a Visual Basic program.) |
• | InstallShield must be installed on the system before you can use the automation interface. |
• | Before running the script, assign the fully qualified path of an existing setup project (.ism file) to the string variable sProj. |
Example Script
Option Explicit
' Create automation object
Dim pProj
Set pProj = CreateObject("IswiAutoAutomation Interface Version.ISWiProject")
' Open a setup project--make sure it is not already open in the IDE
Dim sProj
sProj = "C:\MySetups\TestProject.ism"
pProj.OpenProject sProj
' Start building string that lists features, components, and files
Dim sItems
sItems = "Project Report" & vbNewLine
sItems = sItems & "For project: " & sProj & vbNewLine
sItems = sItems & "Number of features: " & pProj.ISWiFeatures.Count & vbNewLine
sItems = sItems & "Number of components: " & pProj.ISWiComponents.Count & vbNewLine
' Declare and initialize counters for files and file types
Dim i, nEXE, nDLL, nOCX
i = 0
nEXE = 0: nDLL = 0: nOCX = 0
' Loop through components to get the number of files and individual file names
Dim sFileName
Dim pComp, pFile
For Each pComp In pProj.ISWiComponents
For Each pFile In pComp.ISWiFiles
i = i + 1
sFileName = pFile.DisplayName
If Instr (1, sFileName, ".exe", vbTextCompare) > 0 Then
nEXE = nEXE + 1
ElseIf Instr (1, sFileName, ".dll", vbTextCompare) > 0 Then
nDLL = nDLL + 1
ElseIf Instr (1, sFileName, ".ocx", vbTextCompare) > 0 Then
nOCX = nOCX + 1
End If
Next
Next
sItems = sItems & "Number of files: " & i & vbNewLine
sItems = sItems & vbTab & "EXEs: " & nEXE & vbNewLine
sItems = sItems & vbTab & "DLLs: " & nDLL & vbNewLine
sItems = sItems & vbTab & "OCXs: " & nOCX & vbNewLine
' Display report
Wscript.Echo sItems
' Close project
pProj.CloseProject
See Also