Share this page 

Check if a program is runningTag(s): WinAPI/Registry


OleObject locator,service,props
String ls_query = &
 'select name , description from Win32_Process where name = "textpad.exe"'
int num, ret, i
locator = CREATE OleObject
ret = locator.ConnectToNewObject("WbemScripting.SWbemLocator");
service = locator.ConnectServer();
props = service.ExecQuery(ls_query);
num = props.count()

IF num > 0 THEN
 MessageBox("Process","textpad.exe is running")
ELSE
 Messagebox("Process","textpad.exe is NOT running")
END IF
Before using this technique, you may need to download and install the WMI ActiveX, here the URL.

See this related howto