Check and Abort Installer VBA/VBS, InstallShield VSTO C#

Check and Abort Installer VBA/VBS, InstallShield VSTO C#

Check Running Office Application

There are cases when developer in need to check if certain application is running or not, if not so, run it else grab existing instance and start work. Let’s come to the real situation, I was deploying a Office VSTO (consider Excel Add-ins) solution using InstallShield Limited Edition where installation automatically gets aborted if targeted Office application (Excel) is already running. Now I need to create a customize installer which will check if my Excel Application is already running then prompt user with a meaningful message and abort installation. Also post installation launch my excel application automatically.

Above situation looks impossible as InstallShield is a third party application and have its own limitations. But certainly InstallShield has opened a new world of possibilities by providing VBS (Visual Basic Script) customization.

You just need to create your scripts and attach to the respective actions under “Define Setup Requirements And Actions>>Custom Actions

Microsoft VBA implements following two functions to get it done:

  1. GetObject()
  2. CreateObject()

To understand in details please see GetObject() vs CreateObject(), however, below is the final code as we need to abort the InstallShield installer too.

Check if PowerPoint running then prompt user with custom message and abort installation:

Dim objPPT, strMessage
Const IDABORT = 3
PPT_Run
Function PPT_Run()
	On Error Resume Next
	' Try to grab a running instance of PowerPoint:
	Set objPPT = GetObject(, "PowerPoint.Application")

	If Not TypeName(objPPT) = "Empty" Then
		strMessage = "We found PowerPoint Running instance."
		' Feedback to user...
		MsgBox strMessage, vbInformation, "Installer Status"
		' abort the installation
		PPT_Run=IDABORT
	Else
		Set objPPT = GetObject("PowerPoint.Application")
		objPPT.Visible=true
	End If
End Function

Next >> What is Add-in object in Word example

One thought on “Check and Abort Installer VBA/VBS, InstallShield VSTO C#

Leave a Reply

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