Is Process Running

I need to write a Windows console app that checks if a program is running e.g. winword.exe or if it is not responding and if not then return an errorlevel of 1 so that I can then notify someone if the program dies. I am sure I read somewhere on the forum of some way to do this but cannot find it in my searches. Anyone have an idea how I can check the status of a process / application. Thanks.

No idea on Windows, but I’m sure MBS has a plug-in for this, if that’s an option.

Yeah I have looked at MBS and do own it but I just cant see how to do it, maybe Christian may have a suggestion or some else might know a way to do it directly in Xojo.

I have no idea either… also check out WFS… it might have something.

To see if an application is running, shell execute tasklist and look at shell.result for the name of all running processes. Then you can search that data with a simple instr() to see if winword.exe for instance is running.

To know which programs are not responding the shell is :


So if winword.exe is stuck, it will appear in that shell result. Otherwise not.

To force stop a stuck program :

Taskkill /F /IM winword.exe

Is grep available in Windows? Otherwise, I’d use a RegEx over InStr just so there is no confusion. For example, InStr would find “mywinword.exe” too.

Unfortunately, Grep does not exists in Windows. Type and Find are somehow able to do some things, but it is more limited.


Ah, good thing there is RegEx.


Did you look at the examples in the MBS Plugin folder \Examples\Util\Process?

Did you see ProcessMBS class?

I looked in the docs and got confused but have now looked in the Util\Process folder in the Examples and one of the projects looks promising. I will take another look at the ProcessMBS class, I did see it but went a bit over my head. I could not see how I can tell if the application is not responding on Windows. Is this possible using MBS?

you can’t see well if process is responding.
You can see if process is in list of processes.

For responding, well, you could use SendMessage with timeout and see if the window you send message to reacts before timeout.

Ok so how does the task manager know?

Because sometimes using Windows built in system tools is more sensible than reinventing the wheel ? :stuck_out_tongue:

Amazing how simple pragmatic solutions seem unpalatable to some …

Yeah I know but I dont like to do what is right, I prefer to do what is slicker and self contained. If the windows Task List can know if something is not responding then MBS should be able to do :wink:

If the output from Task Manager is consistent, or can be made consistent, you can wrap a class around it and make it self-contained and pretty slick. :slight_smile:

Best quote of the day.

Where do you think MBS gets it’s “self contained” information ? From nowhere ? Would that not be the same system calls as tasklist ?

It is just the thought of running a shell command to get a result is open to issues, for example if the user doesnt have permission to the tasklist.exe or it gets deleted by some overzeolous system administrator etc which is why I prefer to do it as self contained in that it is out of the reach of some third party buggering it up.

Ok maybe the fingers were going a bit quicker than the brain :wink: What I meant was, I dont like to do it the easy way if it is glue and sticky tape, that would be fine for internal use but not so good for use by third parties. I have sysadmins who do things that you would never think of e.g. renaming taskmgr.exe, cmd.exe,

I have just tested Michels suggestion and it works really well and what I am going to do is check if the tasklist.exe exists before I do the shell and if not stop the program running cleanly. Thanks for the help.