Powered by: Dharamveer Saxena

Wednesday, January 30, 2013

How to check if a process is still running in your windows


Many times your script need to know if a program or for example a bat file is still running. so, how you can check it using VBScript.

Below is the code which you can use to check if a process/program is still running

sub p_check()
with createobject("shell.application")
 for each wndw in .windows
   locationurl_ = cstr(wndw.LocationURL)
   if InStr(locationurl_, "locationurl") = 0 then
'here in locationurl you can pass the name of the bat file
 
else
'to quit the bat file if needed after script found it
     wndw.quit
end if
next
end with
End sub


Here, using wndw object in for each loop you can check the process based on its application name as well in which it is open for example iexplorer but you need to use correct method to get values based on your need

No comments:

Post a Comment