General information
Category:
Coding, syntax & commands
Sergey - can non-admin Vista users run this code? I am looking for a FindWindow replacement, which does not work with Vista.
>>* Terminate EXE if it's running
>>? IsExeRunning(lcExeName, .T.)
>>
>>RETURN
>>
>>FUNCTION IsExeRunning(tcName, tlTerminate)
>>LOCAL loLocator, loWMI, loProcesses, loProcess, llIsRunning
>>loLocator = CREATEOBJECT('WBEMScripting.SWBEMLocator')
>>loWMI = loLocator.ConnectServer()
>>loWMI.Security_.ImpersonationLevel = 3 && Impersonate
>>
>>
>>loProcesses = loWMI.ExecQuery([SELECT * FROM Win32_Process WHERE Name = '] + tcName + ['])
>>llIsRunning = .F.
>>IF loProcesses.Count > 0
>> FOR EACH loProcess in loProcesses
>> llIsRunning = .T.
>> IF tlTerminate
>> loProcess.Terminate(0)
>> ENDIF
>> ENDFOR
>>ENDIF
>>RETURN llIsRunning
Previous
Next
Reply
View the map of this thread
View the map of this thread starting from this message only
View all messages of this thread
View all messages of this thread starting from this message only