Checking whether a program is running or not

While performing installation, sometimes, we need to check whether the instance of a particualr program exist or not.

I got this problem while installing my plug-in. Outlook should be closed before the installation starts. So, I need to check for the existance of Outlook before installation. After so many days and lot of efforts, finally I have got a solution for this.

While Process.GetProcessesByName(“Outlook”).Length > 0

MsgBox(“Notepad is open”)
End While

MsgBox(“Outlook is still open. Please close it”)

End While

This loop will iterate until the Outlook is closed.

We can also close a program forcibly using the following code.

Dim myProcesses() As Process

Dim instance As Process

myProcesses = Process.GetProcessesByName(“Outlook”)

For Each instance In myProcesses

instance.CloseMainWindow() ‘ This will close the application that is running

Next

Advertisements

3 thoughts on “Checking whether a program is running or not

  1. I am trying to do the same thing in c#, where and how would I do this? Sorry, this is the first time I am creating an installer.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s