📜 ⬆️ ⬇️

Console windows- "zombies", or how to restart Windows without stupid questions


It was not the first time yesterday that I encountered a funny problem in Windows Server 2008 - after I quit FAR Manager, I had to hang a zombie console window.

This window has a truly remarkable property - it can not be closed. In addition, if you have such a window, you will not be able to restart Windows - all your attempts will end with the message in the Event Log The attempt by user *** *** to restart / shutdown computer *** failed .

Against this background, the absence of an appropriate process in the task list seems such a trifle ... ;-)


')
My yesterday's problem was aggravated by the fact that it appeared just after deploying a new version of the application, and for its successful completion, I definitely had to restart the server. When I came across a zombie window problem earlier, I stopped all services and rebooted the server on power. But yesterday I had no such opportunity - the server was, to put it mildly, very far, IP-KVM was not connected to it, and local staff who could apply extreme measures to the server were also unavailable.

By the way, I tried the shutdown and psshutdown utilities in the first few minutes, no effect. Apparently, they use the same ExitWindowsEx () call, which sends out lots of notifications, waits for them to be answered, and so on.

In a hurry, having thrown the application on another server, I began to search, how can I solve this problem?

After talking with friends, I found out that I was not the only one who had encountered this problem, but they could not tell me the solution, because just like me, they “solved” it by turning off the power to the server.

After I had a little more digging into i-net, I had a suspicion who was to blame for my torment - according to VS Debugger Team , the problem was caused by an error in csrss (Client / Server Runtime Subsystem) , and it appeared more than a year ago, after The release of update KB978037 , and in this same KB article is a link to hotfix ( KB982551 ). And despite the fact that in the list of operating systems that this error affects, Windows Server 2008 is missing, the symptoms are very similar.

Unfortunately, installing a circle of suspects did not bring me much closer to solving the problem, and I continued my search. Very quickly, I found information that in Windows 2000 there was an Emergency Shutdown feature:

HOW TO: Perform an Emergency Shutdown in Windows
http://support.microsoft.com/kb/279134/en-us

Unfortunately, because of the changed interface, I could not find out whether such a function remained in Windows Server 2008 (the search for “emergency shutdown windows 2008” did not bring any results), but here’s a discussion 10 years ago on the CodeGuru website Dedicated to this function, gave me the idea to use the NtShutdownSystem () call to reboot.

Having consulted just in case with Mark Russinovich (in his printed hypostasis ;-), I decided that yes, this is what we need! And taking as a basis the code that Alex Fedotov (unfortunately, the link to his home page is not working now ... but maybe he will read this post and I can thank him? :) resulted in the discussion mentioned above, I wrote a small a utility, a slightly refined version of which can be downloaded from the link at the end of the post.

And this utility helped me! And if I still managed to check her work on a specially launched virtual machine, and not on my workstation, while losing some unsaved data, I would be just insanely happy! ;-)

By the way, after I solved the problem, on the TechNet forum I was offered another option, namely, to execute the shutdown utility on behalf of the system account, but I haven’t checked the operation of this option yet.

Download Force Reboot Utility (source code + binary)

Source: https://habr.com/ru/post/117083/


All Articles