Forum Discussion

joe_2's avatar
joe_2
Contributor
11 years ago
Solved

How to test for the presence of a process, without generating an error if it is not there.

Need to test whether a given process is running without generating an error when it isn't.



I have tried:

If (Sys.Process("MyProcess").Exists = true) then...

and

If (Not Sys.Process("MyProcess") Is Nothing) then...

and

If object (Sys.Process("MyProcess")) Exists keywords



I keep getting "The process doesn't exist" errors.



Can't seem to find that magical way to test it without generating an error if it isn't there...

Anyone know a way?

VBScript or keyword will do.







  • Hi Joseph.



    Use WaitProcess instead:



    If ( Sys.WaitProcess( "MyProcess", 1000 ).Exists ) then...



    1000 = waiting time in ms. If you don't need to wait your process to appear, just omit this parameter.




3 Replies

  • Hi Joseph.



    Use WaitProcess instead:



    If ( Sys.WaitProcess( "MyProcess", 1000 ).Exists ) then...



    1000 = waiting time in ms. If you don't need to wait your process to appear, just omit this parameter.




  • WaitProcess.

    That's what I was looking for, thanks.



    Always love it when the solution to a problem is a previously unknown (to me) single command...

    Learned a little more about VBasic and solved the issue at the same time.