0

I just got a windows command prompt to freeze and I could not close it from another terminal with taskkill /IM cmd.exe /T /F

I had to open task manager and and when trying to end the task got a pop up window where I add to check an "abandon unsaved data and shut down" checkbox, and then the terminal closed.

I would have thought the /F would deal with such things, but it does not.

How can I kill such a process from the commandline?

Seb
  • 1,765
  • 9
  • 23
  • cmd.exe is not the console. It's just a shell that uses a console. So forcefully killing it has no effect on other processes attached to the console. The `/T` option forcefully kills the known child processes, but it can't kill orphaned descendants. Windows doesn't maintain a process tree, so a process is orphaned when its parent exits. – Eryk Sun Oct 24 '19 at 17:58
  • 1
    To kill a console session, non-forcefully kill the process that effectively owns the console window (typically the process that allocated the console). This sends `WM_CLOSE` to the console, which in turn sends a control-close event to all processes attached to the console. They have 5 seconds to exit on their own before the system terminates them. If you combine it with `/T`, taskkill.exe will also send `WM_CLOSE` to the top-level or message-only windows of non-orphaned child processes -- whether the windows are visible or not and whether the child is attached to the console or not. – Eryk Sun Oct 24 '19 at 18:02

0 Answers0