Notice: This forum has been recovered from an old backup, so some content, links, and dates may be outdated. The forum is currently read-only while we restore sign-in and registration functionality. Details

If you find this forum valuable and would like to help keep it online, donations to help cover hosting and domain costs are greatly appreciated, but never expected. You can support the forum through Buy Me a Coffee or Ko-fi. Thank you for helping preserve the EventGhost community.

How to check status of process

If you have a question or need help, this is the place to be.
Post Reply
User avatar
Luca Brasi
Experienced User
Posts: 262
Joined: Sat Oct 11, 2008 12:39 pm

How to check status of process

Post by Luca Brasi »

Hi guys,

I'd like to do something which shouldn't be a problem for the experts here.
As I'm not, I'm just gonna ask:

I want to execute some macros just in case a special process is running.
If it's not the macro should stop.

I have several use cases for this. E.g. sometimes mediaportal won't close on close command so I want to check the macro a few seconds later if it is still running. If so I would run a kill.bat

Could you please help me out?

Thanks
Luca
Win10 x64 Prof. / Eventghost latest / MCE Plugin / MCE RC6 Receiver / Logitech Harmony Hub / MediaPortal / kodi
User avatar
Luca Brasi
Experienced User
Posts: 262
Joined: Sat Oct 11, 2008 12:39 pm

Re: How to check status of process

Post by Luca Brasi »

Hey guys,

come on, this should be a no-brainer for you! Would be very grateful for some help!

Thanks
Luca
Win10 x64 Prof. / Eventghost latest / MCE Plugin / MCE RC6 Receiver / Logitech Harmony Hub / MediaPortal / kodi
User avatar
Luca Brasi
Experienced User
Posts: 262
Joined: Sat Oct 11, 2008 12:39 pm

Re: How to check status of process

Post by Luca Brasi »

Sorted it out:

Code: Select all

from win32com.client import GetObject
WMI = GetObject('winmgmts:')
eg.result = len( WMI.ExecQuery('select * from Win32_Process where Name="mediaportal.exe"') ) > 0
Win10 x64 Prof. / Eventghost latest / MCE Plugin / MCE RC6 Receiver / Logitech Harmony Hub / MediaPortal / kodi
kalia
Experienced User
Posts: 109
Joined: Wed Aug 12, 2009 1:10 am

Re: How to check status of process

Post by kalia »

Thanks Luca for posting the solution. I didn't realize that I needed something like this until you posted the code.
User avatar
Luca Brasi
Experienced User
Posts: 262
Joined: Sat Oct 11, 2008 12:39 pm

Re: How to check status of process

Post by Luca Brasi »

Thanks for your reply kalia.
Just want to mention that I took it from this german post
Win10 x64 Prof. / Eventghost latest / MCE Plugin / MCE RC6 Receiver / Logitech Harmony Hub / MediaPortal / kodi
Post Reply