Search code examples
windowsbatch-filevirtualboxtaskkill

Batch error loop: Batch file execute by "mistake" another batch file when it opened


I have 2 batch files: kill_window1.bat & kill_host.bat. The content of bats are:

  • kill_window1.bat:

    taskkill /f /im some_program.exe
    
  • kill_host.bat

    taskkill /f /im taskhost.exe
    

The problem is that when I execute kill_window1.bat, it's like if I had executed kill_host.bat, and also, the process never ends, because cmd window never ends and still printing the line but nothing happens, just still open and my O.S. crash by more than 20 cmd's.

I'm using Windows 7 in a virtualbox.

Sorry if my English isn't perfect. I'm still learning ;)

PD: I'm killing taskhost.exe because sometimes use 100% CPU.


Solution

  • Try to use PsKill instead. Btw, it's strange that OS crashes. I hope the "some_program.exe" is not an OS process? Also, it's not a good idea to kill the taskhost.exe. Instead, try to discover which service loads CPU so high and stop only the service instead killing the host that can host several services.