Link to home
Start Free TrialLog in
Avatar of IT CAMPER
IT CAMPERFlag for United States of America

asked on

Is it possible to create a script or batch to taskkill on application close?

I have an exe application that throws a .NET error when you close the GUI.  The .NET error is persistent and requires that you 'end process' on the exe in order to get rid of the error and actually close the running exe.  I have created a batch that I can run using taskkill /IM application.exe /F and it kills the exe and will also kill the .NET error.  My question is this.  Can I have a script or batch file launch the exe application (instead of using the actual exe shortcut) and then when I close the GUI, the script or batch will taskkill the exe process for me?  Currently, I launch the exe with its default shortcut, then have to launch the taskkill batch after I close the GUI.  Most of my users will either forget or will still be upset with the extra step.  Any options here?
Avatar of compaqus
compaqus
Flag of Canada image

Usually a bat file will wait until the command is complete (program closed) then continue.

Just tested that.

you can also put the command to run the application in second.bat and then, from the first.bat, use "call second.bat" and then the kill thing. It will wait until the other bat is finished.
the thing is, if the exe is still running the bat will not continue.... hmm...
ASKER CERTIFIED SOLUTION
Avatar of compaqus
compaqus
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of IT CAMPER

ASKER

you guessed it.  I wonder if it is possible for a script or batch to monitor the existence of the GUI.  It closes, but the exe remains running.
I know what would work, but I need someone to build the script...

Script this.

launch exe application
open small dialog box with button that says Close Application.
place the dialog box at the very top left corner of the desktop
user will then use the applciation and close it
.NET error will appear but user will just click the close application button in the desktop corner
button will execute taskkill /im application.exe /f
script will end
the other application you suggested requires installation. I am trying to do this without having to install anything.  I think the script action above will work, just need someone to script it for me.