Unable to taskill some cmd.exe instances
Posted: 02 Aug 2022 09:23
Long story short: by a mistake a created a BAT file with a looped execution of itself. This resulted in multiple CMD icons appearing extremely fast on and disappearing from my Taskbar
So instead of just resetting the system I went to
Task Manger > Process
and closed Windows Command Processor. But it did not work, as it instantly was right back. So I quickly wrote this
script and then very quickly executed it multiple times with a left mouse button clicks of BAT file holding it. And it worked, i.e. the Taskbar was clear of CMD icons and Task Manger was also showing no signs of Command Prompt
So then I wanted to be sure that this BAT will work always. So I executed
C:\Windows\system32\cmd.exe
both normally and As Administrator and once again executed my newest BAT. And [surprise] it did not work. So I went to
Task Manger > Details > cmd.exe > [RIGHT CLICK] End Task
and [surprise, surprise] it also did not work. But when I tried
Task Manger > Details > cmd.exe > [RIGHT CLICK] End Process Tree
it did work. The same case was with the other cmd.exe instance. And so I went back to my BAT and reworked it to
but [surprise, surprise, surprise] it did not work
I also repeated some time later my test- and to my [this time real] surprise End Task in Task Manger was able to close without a sweat all of my cmd.exe instances. But nevertheless that BAT file still was not able to do so
So how can I 100% taskkill every instance of cmd.exe - or - is there an alternative command for BAT scripts for closing of programs? Or maybe some PS1 script could take care of this issue? [A PowerShell script could be even better as it could execute taskkill or similar command multiple time, with some time delays in-between]
I am using Windows 10 Enterprise 20H2 19042.746 x64
So instead of just resetting the system I went to
Task Manger > Process
and closed Windows Command Processor. But it did not work, as it instantly was right back. So I quickly wrote this
Code: Select all
taskkill cmd.exe /F
So then I wanted to be sure that this BAT will work always. So I executed
C:\Windows\system32\cmd.exe
both normally and As Administrator and once again executed my newest BAT. And [surprise] it did not work. So I went to
Task Manger > Details > cmd.exe > [RIGHT CLICK] End Task
and [surprise, surprise] it also did not work. But when I tried
Task Manger > Details > cmd.exe > [RIGHT CLICK] End Process Tree
it did work. The same case was with the other cmd.exe instance. And so I went back to my BAT and reworked it to
Code: Select all
taskkill /F /IM /T cmd.exe
I also repeated some time later my test- and to my [this time real] surprise End Task in Task Manger was able to close without a sweat all of my cmd.exe instances. But nevertheless that BAT file still was not able to do so
So how can I 100% taskkill every instance of cmd.exe - or - is there an alternative command for BAT scripts for closing of programs? Or maybe some PS1 script could take care of this issue? [A PowerShell script could be even better as it could execute taskkill or similar command multiple time, with some time delays in-between]
I am using Windows 10 Enterprise 20H2 19042.746 x64