Jump to Real's How-to Main page

Detect if a program is running

Set WshShell = WScript.CreateObject("WScript.Shell")

Set locator = CreateObject("WbemScripting.SWbemLocator")
Set service = locator.ConnectServer()
Set props = service.ExecQuery _
   ("select name, description from Win32_Process where name = 'program.exe'")
num = props.Count

If num > 0 Then
   'Program is running
Else
   'Program is not running
End If

Set WSHShell = Nothing


If you find this article useful, consider making a small donation
to show your supportfor this Web site and its content.

Written and compiled by Réal Gagnon ©1998-2005
[ home ]