WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

Process ID

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

Check if a Remote Process is Running

 Keywords: remote application process exists running 

Question:

Is there a way to check if a process is running on a remote machine?

Answer:

Yes, using the Process Extender. The tRemoteConn function allows you to access a remote machine and the tGetData function can grab process information. Using these function we can check if the process is running or not.

The following 'performance counter string' allows you grab the process ID of a Process.

\\TestMachine\Process(popmenu)\ID Process
If that process doesn't exist, the tGetData function would throw a 225 Error, which would indicate the process doesn't exist.
;Addextender("wproc34i.dll")
Addextender("wwprc44i.dll")
computername = "\\TestMachine"
procname = "popmenu"
counterstring = StrCat(computername,"\Process(",procname,")\ID Process")
;Connects to the remote machine
ErrorMode(@Off)
ret = tRemoteConn(computername)
ErrorMode(@Cancel)
if ret==0
  Message(StrCat("Unable to connect to ",computername),StrCat("For the following reason:",@CRLF,"Extender Error ",LastError(),@CRLF,tGetLastError()))
  exit
endif
;Message("tBrowseCntrs returned full counter path",counterstring)
ErrorMode(@Off)
dat=tGetData(counterstring,0)
ErrorMode(@Cancel)
;capture possible error 225, if process doesnt exist
if LastError()==225
   Message(procname, "Does NOT Exist")
else
   Message(procname, "Exists")
endif

exit

Article ID:   W15076
File Created: 2017:07:28:13:58:38
Last Updated: 2013:04:01:09:08:20