Solved

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

Posted on 2010-09-10
6
587 Views
Last Modified: 2012-05-10
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?
0
Comment
Question by:murryc
  • 3
  • 3
6 Comments
 
LVL 7

Expert Comment

by:compaqus
Comment Utility
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.
0
 
LVL 7

Expert Comment

by:compaqus
Comment Utility
the thing is, if the exe is still running the bat will not continue.... hmm...
0
 
LVL 7

Accepted Solution

by:
compaqus earned 500 total points
Comment Utility
0
What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 

Author Comment

by:murryc
Comment Utility
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.
0
 

Author Comment

by:murryc
Comment Utility
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
0
 

Author Comment

by:murryc
Comment Utility
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.  
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

I met Paul Devereux (@pdevereux) today when I responded to his tweet asking “Anybody know how to automate adding files from disk to a folder in #outlook  ?”.  I replied back and told Paul that using automation, in this case scripting, to add files t…
Over the years I have built up my own little library of code snippets that I refer to when programming or writing a script.  Many of these have come from the web or adaptations from snippets I find on the Web.  Periodically I add to them when I come…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now