0

I'm trying to run a batch file that will close a different cmd window. I know I can do this:

TASKKILL /IM "myapplication.exe" /F

But whilst this does (obviously) kill the task, it doesn't close the cmd window myapplication.exe was running in. I cannot edit myapplication.exe or I would put an 'exit' on the last line.

Any help would be much appreciated.

Kev
  • 143
  • 1
  • 1
  • 8
  • How is your application started resulting in not closing command processor after started application terminated itself? – Mofi Sep 07 '15 at 19:28
  • I'm using [McAfee's Rootkit Remover](http://www.mcafee.com/uk/downloads/free-tools/rootkitremover.aspx) tool which is not an install, its a run once type thing. But, I want to run it every night so I'm running the exe via Windows Task Scheduler. However, the exe doesn't close itself after running. You have to press a key to get it to shut. So, what I did was create a batch file with the code above which is also scheduled to run, but 10 mins later when the exe will have finished scanning. – Kev Sep 07 '15 at 19:33
  • Your comment does not answer my question. How exactly is Rootkit Remover tool started? What is the command line used to start it? For example using `cmd /K "Path\application.exe"` starts the application, but because of `/K` the command window is kept open for user input after application terminated. Or is the application started with a batch file? What is the command line in the batch file? Depending on how the application is started, a specific title for the console window can be set making it possible to close that window from other application. – Mofi Sep 07 '15 at 19:43

1 Answers1

0

Well, if your program was started from cmd, then obviously cmd is still running even if you kill or exit that application. To kill cmd as well you can apply the same command to a different program (in a quite obvious way).

However, this will also stop your batch file for equally obvious reasons.

Is there a particular need to run myapplication from cmd?

Joey
  • 344,408
  • 85
  • 689
  • 683