This was tested with Vista, Windows XP, Office 2007 and Office 2003.
I pieced this quickly together from other sources on the internet.
Save the below code as a .vbs file.
Function IsProcessRunning( strServer, strProcess )
Dim Process, strObject
IsProcessRunning = False
strObject = "winmgmts://" & strServer
For Each Process in GetObject( strObject ).InstancesOf( "win32_process" )
If UCase( Process.name ) = UCase( strProcess ) Then
IsProcessRunning = True
On Error Resume Next
Dim strComputer, strProcess
strProcess = "outlook.exe"
strComputer = "."
If( IsProcessRunning( strComputer, strProcess ) = True ) Then
Set Outlook = GetObject(, "Outlook.Application")
If Err = 0 Then
WScript.Echo "Process " & strProcess & " is NOT running on computer " & strComputer
To apply this script so it runs on shutdown and/ or logoff do the following,
Goto Start > Run
In Run window, type gpedit.msc, hit enter.
In the GPEDIT window, under User Configuration,
Goto Windows Settings
Goto Scripts (Logon/Logoff)
Choose add and browse to your recently created .vbs script.
This could also work from a Domain applied group policy object.
I also use it on a server to shutdown outlook that I have setup running as a service. I applied the script as a computer shutdown script.