Wilson WindowWare Tech Support

WinBatch WinBatch+Compiler WebBatch
Home | Tech Database | Tech BBS | White Papers | Purchase


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")

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