How to check status of process

If you have a question or need help, this is the place to be.

How to check status of process

Postby Luca Brasi » Sat Jun 16, 2012 1:17 pm

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
Win7 x64 Prof. / Eventghost latest / auvisio vrc-1100-plugin and MCE Plugin / auvisio vrc-1100 and MCE Receiver / Logitech Harmony One / MediaPortal / XBMC / PowerDVD / ffdshow
User avatar
Luca Brasi
Experienced User
 
Posts: 61
Joined: Sat Oct 11, 2008 12:39 pm

Re: How to check status of process

Postby Luca Brasi » Mon Jun 18, 2012 6:00 pm

Hey guys,

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

Thanks
Luca
Win7 x64 Prof. / Eventghost latest / auvisio vrc-1100-plugin and MCE Plugin / auvisio vrc-1100 and MCE Receiver / Logitech Harmony One / MediaPortal / XBMC / PowerDVD / ffdshow
User avatar
Luca Brasi
Experienced User
 
Posts: 61
Joined: Sat Oct 11, 2008 12:39 pm

Re: How to check status of process

Postby Luca Brasi » Mon Jun 18, 2012 8:15 pm

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
Win7 x64 Prof. / Eventghost latest / auvisio vrc-1100-plugin and MCE Plugin / auvisio vrc-1100 and MCE Receiver / Logitech Harmony One / MediaPortal / XBMC / PowerDVD / ffdshow
User avatar
Luca Brasi
Experienced User
 
Posts: 61
Joined: Sat Oct 11, 2008 12:39 pm

Re: How to check status of process

Postby kalia » Wed Jun 20, 2012 3:08 am

Thanks Luca for posting the solution. I didn't realize that I needed something like this until you posted the code.
kalia
Experienced User
 
Posts: 64
Joined: Wed Aug 12, 2009 1:10 am

Re: How to check status of process

Postby Luca Brasi » Thu Jun 21, 2012 4:13 pm

Thanks for your reply kalia.
Just want to mention that I took it from this german post
Win7 x64 Prof. / Eventghost latest / auvisio vrc-1100-plugin and MCE Plugin / auvisio vrc-1100 and MCE Receiver / Logitech Harmony One / MediaPortal / XBMC / PowerDVD / ffdshow
User avatar
Luca Brasi
Experienced User
 
Posts: 61
Joined: Sat Oct 11, 2008 12:39 pm


Return to General Support

Who is online

Users browsing this forum: Bing [Bot], Google Adsense [Bot] and 4 guests