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.

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

Postby e2zippo » Mon May 14, 2012 2:25 pm

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.
e2zippo
 
Posts: 4
Joined: Mon May 14, 2012 1:59 pm

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

Postby wakko » Wed May 16, 2012 5:15 pm

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.
User avatar
wakko
 
Posts: 25
Joined: Sat Aug 20, 2011 9:27 pm
Location: Russia, Siberia

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

Postby e2zippo » Thu May 17, 2012 11:14 pm

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!
e2zippo
 
Posts: 4
Joined: Mon May 14, 2012 1:59 pm

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

Postby Livin » Fri May 18, 2012 2:19 am

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
User avatar
Livin
Experienced User
 
Posts: 749
Joined: Wed Oct 08, 2008 4:56 am

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

Postby e2zippo » Fri May 18, 2012 6:29 pm

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!
e2zippo
 
Posts: 4
Joined: Mon May 14, 2012 1:59 pm

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

Postby Livin » Fri May 18, 2012 9:23 pm

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
User avatar
Livin
Experienced User
 
Posts: 749
Joined: Wed Oct 08, 2008 4:56 am


Return to General Support

Who is online

Users browsing this forum: No registered users and 3 guests