
Detecting Exitcode of an external process
Detecting Exitcode of an external process
I need to execute a process and inspect the exitcode of the process. Is there a way to do that using System Execute action? Alternately, can a python command/script be written to do this using spawn... commands? (I tried to call os.spawnlp but get a error: module object has no attribute spawnlp). I'm not a Python programmer 

Re: Detecting Exitcode of an external process
One simple way to do it is to use a batch file like this one to launch the app:
So, after the program finishes trigger an action with the %ERRORLEVEL% in the eg.event.payload variable. Or you could put the errorlevel as the name of the action if you prefer it that way.
I think it should be also possible to do it with a script, but I've never tried it. The python docs probably come in handy if you want to look into it.
http://docs.python.org/library/subprocess.html
http://docs.python.org/library/os.html
-jinxdone
Code: Select all
myapp.exe
"C:\Program Files\EventGhost\EventGhost.exe" -e errorlevel %ERRORLEVEL%
I think it should be also possible to do it with a script, but I've never tried it. The python docs probably come in handy if you want to look into it.
http://docs.python.org/library/subprocess.html
http://docs.python.org/library/os.html
-jinxdone
- Bitmonster
- Site Admin
- Posts: 2239
- Joined: Mon Feb 06, 2006 10:28 pm
Re: Detecting Exitcode of an external process
System.Execute in 0.3.7.r1170 returns the exit code as eg.result if "wait for completion" is checked.
Please post software-related questions in the forum - PMs will only be answered, if really private, thanks!
Re: Detecting Exitcode of an external process
Since Bitmonster added this into EG properly everybody should disregard my previous post. Thanks again Bitmonster!
-jinxdone
-jinxdone
Re: Detecting Exitcode of an external process
Bitmonster, thanks for the new version. Works like a charm 
jinxdone, thanks for the info. I did look at the Python docs which is where I got the syntax for spawn... etc. General question though - can any python command be called (after importing relevant module) or are there some security restrictions?

jinxdone, thanks for the info. I did look at the Python docs which is where I got the syntax for spawn... etc. General question though - can any python command be called (after importing relevant module) or are there some security restrictions?
Re: Detecting Exitcode of an external process
There should be no restrictions. Some things are already implemented in EG though, so you don't have to create everything from scratch. Check out the "help -> python shell", it can be quite useful.
If you have experience in programming with some other language just read the python tutorial and you can probably get started with scripts in EG without problems.
Oh, and welcome!
-jinxdone
If you have experience in programming with some other language just read the python tutorial and you can probably get started with scripts in EG without problems.
Oh, and welcome!

-jinxdone
Re: Detecting Exitcode of an external process
???jinxdone wrote:There should be no restrictions.nkapur wrote: or are there some security restrictions?
If that were true, we wouldn't have problems with the Mce Remote on Vista and Win7, right? Unless you run EG as admin or with UAC off, you won't be able to do things you "normally" wouldn't be able to do, such as change system files. Sorry to jump in at the end here, but I've been working on an alternate Mce Remote capability, so I thought this was worth mentioning.
Brett
Re: Detecting Exitcode of an external process
Well, thats a feature of Vista/Win7 and not really a restriction in EG. As far as I know the same happens for any other program you run on Vista/Win7 that tries to work with drivers or write system files.