tags:

views:

847

answers:

2

Hi,

How to check if Outlook is running, using vbscript, I need this for my installation procedure to ask the user to close outlook before installing my application.

Thanks,

+2  A: 
Dim Process, strObject, strProcess
Const strComputer = "." 
strProcess = "OUTLOOK.exe"
IsProcessRunning = False
strObject   = "winmgmts://" & strComputer
For Each Process in GetObject( strObject ).InstancesOf( "win32_process" )
If UCase( Process.name ) = UCase( strProcess ) Then
        MsgBox "Outlook is running"
    End If
Next
Beware... is my vista64 version going to be an instance of a win32_process ??
Karl
+1  A: 

You could try obtaining the Outlook Application object using the GetObject function. If the function call succeeds, this means that Outlook is currently running:

On Error Resume Next
Dim Outlook: Set Outlook = GetObject(, "Outlook.Application")

If Err.Number = 0 Then
  ' Outlook is running
Else
  ' Outlook is not running
  Err.Clear
End If
Helen
I think you need a comma (pathname, class): GetObject(, "Outlook.Application")
Remou
Fixed, thanks.
Helen