Forum Discussion

edrider's avatar
edrider
New Contributor
14 years ago

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

  Else

       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?

1 Reply

  • sbkeenan's avatar
    sbkeenan
    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

    Stephen.