Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.
Keywords: AppExist udfAppExist Application Exist Fast GetTickCount Process Win32_Process WMI
AppExist(program-name [, flags [, retries]])By default, AppExist and AppWaitClose retry up to 7 times (with a half-second delay between tries) before returning, if the specified application doesn't exist. You can override this by specifying a different value for "retries", which may be >= 0 (0 = no retries).
For 2007A and older you can use this WMI code.
#DefineFunction udfAppExist(processname) ; Computer name and current scripts process id. strComputer = "." retvalue = 0 objWMIService = ObjectGet("winmgmts:{impersonationLevel=impersonate}!\\":strComputer:"\root\cimv2") ; Get this script's sessionId strQuery = "select * from win32_process where Name = '":processname:"'" colProcesses = objWMIService.ExecQuery( strQuery ) ForEach objProcess In colProcesses procid = objProcess.ProcessId If procid > 0 Then retvalue = 1 Break Next objProcess = 0 colProcesses = 0 objWMIService = 0 Return retvalue #EndFunction programname = 'notepad.exe' ;Run( programname, "" ) ;WinWaitExist('~Notepad', 10) starttick = GetTickCount() ret = udfAppExist (programname) endtick = GetTickCount() If ret Pause('Notice','Application Exists') Else Pause('Notice','Application Does Not Exist') EndIf Pause('AppExist test results (in milliseconds)', endtick-starttick) Exit
Article ID: W18479
Filename: Fast AppExist UDF.txt
File Created: 2011:06:02:11:52:22
Last Updated: 2011:06:02:11:52:22