Ask a Question

check if process is running script

New Contributor

check if process is running script

Hello, I have a problem with the following vb script.

If (Sys.Process("x").Exists) Then

       do A

  ElseIf (Not Sys.Process("x").Exists) Then

       do B


       do C

  End If

When I run this script when process x is NOT running, it "does B" successfully, but still outputs 2 errors into the log saying that it could not find process x when executing the first if statement, and that it could not find x when executing the elseif either.

I do not want to see any errors.

I want to perform the action "do A" if the process is running, and "do B" if the process is not running.

What am I doing wrong?
Frequent Contributor

Hi Ed

I think you might be looking for the WaitProcess method.  This waits for a specified length of time to see if the specified process exists, without posting an error.

You can get full details on its use if you look up the topic in the on-line help.

Hope this helps.

Best regards

Showing results for 
Search instead for 
Did you mean: