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.

Need som help with with killing a process IF it exists.

If you have a question or need help, this is the place to be.
Post Reply
e2zippo
Posts: 4
Joined: Mon May 14, 2012 1:59 pm

Need som help with with killing a process IF it exists.

Post by e2zippo »

Hey guys, just started using EG and I'm really blown away with what you can do with the program, amazing stuff!

I've tried to find a way to to this thing but I've been unsuccsesful so far.

This is how my setup works so far.

I'm using XBMC and the addon Rom Collection Browser to launch my emulators, and I'm using the wiimote as a gamepad.
To be able to use the wiimote I need glovePIE and since I have three different emulators I'm using three different scripts in glovePIE.

What I want to acheive is that when one emulator launches from xbmc (let's say Snes9x) I want it to look for glovePIE.exe and IF it exists, I want to kill it then launch it again (i'm using bat-files that automatically launches glovePIE with different scripts) based on which emulator that launches.

Would greatly appreciate some help!

I'm running Windows 7 x64 and Eventghost version 0.4.1.r1568.

Cheers!
Last edited by e2zippo on Wed May 16, 2012 6:06 pm, edited 1 time in total.
User avatar
wakko
Posts: 33
Joined: Sat Aug 20, 2011 9:27 pm
Location: Russia, Siberia

Re: Need som help with with killing a process IF it exists.

Post by wakko »

Say, you want to kill sol.exe, for example.
In WinXP you can do it with console command:

Code: Select all

taskkill /F /IM "sol.exe" /T > nul 2>&1
Note, "> nul 2>&1" here is to silence any stderr or stdout from taskkill.
Also, you need to know exact program name you wish to kill.
e2zippo
Posts: 4
Joined: Mon May 14, 2012 1:59 pm

Re: Need som help with with killing a process IF it exists.

Post by e2zippo »

Thanks, made a bat file for it!

But I have a problem with another thing, one program (PIEFree) always ends up on top of my emulator (bsnes.exe).

And there's a lot of stuff that flips in and out in my setup, is there any way to make it "cleaner", so that almost nothing shows during the launch process?

Here my setup!

Image

My bat files look like this.

Classic_NES.bat
".\\PIEFree.exe -Classic_NES.PIE"
&
kill glovepie.bat
"taskkill /F /IM PIEfree.exe /T > nul 2>&1"

Why does PIEFree always end up on top?

Would love some help to optimize this setup :)

Cheers!
User avatar
Livin
Experienced User
Posts: 792
Joined: Wed Oct 08, 2008 4:56 am

Re: Need som help with with killing a process IF it exists.

Post by Livin »

Everything you are trying to do can be done with native actions, no bat files or process killing needed.

Use Start Program with command line options
- using a .bat file is not necessary, and is why you see popup windows

Use the Find Window then Close action to close a program. No need to worry about IF it exists - it is not needed.
- if you find, for some reason you must kill the process (again, this should not be necessary in most cases) you should use python code...

Code: Select all

import os
os.system("taskkill /im <YOUR EXE GOES HERE> /f")
One suggestion... Trigger actions that close apps automatically when other ones open, thus when EG sees the app launching.

Simple Example Macro, macro items bolded --- with comments to explain...

Task.Activated.APP1
--- event "detects" when APP1 starts, which triggers the macro to run
Trigger event "APP2.close"
--- starts macro to close the other app(s), you can do the Find Window / Close here without a separate macro but I prefer separate macros, makes it easier to expand/change later
Enable exclusive: APP1 controls
--- look up this function, it allows easy switching of what has control, and receives IR, keystrokes, etc


hope this helps
setup... XBMC, W7MC for DVR & Live OTA TV, JRMC for multi-zone audio, EG, MiCasaVerde Vera3, USB-UIRT IR receiver, Harmony remote, 5.2 home theater system
e2zippo
Posts: 4
Joined: Mon May 14, 2012 1:59 pm

Re: Need som help with with killing a process IF it exists.

Post by e2zippo »

Hey! Thanks!

A lot of nice info there, and you're right about the bat files, I don't need them :)

However, I'm having trouble getting glovepie (PIEFree.exe) to start at all now.

Should I use Task.Activated.nestopia or Task.Created.nestopia, and under wich macro should these items go?

Could you tell me what I'm doing wrong here, (I'm guessing there's a lot), but I can're really figure it out :roll:

Image

Ignore the SNES part, I figured I'd set that up properly once I got NES going.



Cheers!
User avatar
Livin
Experienced User
Posts: 792
Joined: Wed Oct 08, 2008 4:56 am

Re: Need som help with with killing a process IF it exists.

Post by Livin »

It is pretty easy....
Items with a lightning Bolt are 'things that already happened' - thus can be triggers that macros

everything else are things you want to happen after the macro starts.
setup... XBMC, W7MC for DVR & Live OTA TV, JRMC for multi-zone audio, EG, MiCasaVerde Vera3, USB-UIRT IR receiver, Harmony remote, 5.2 home theater system
Post Reply