r/sysadmin • u/-Steets- • Jul 03 '22
Question Windows' undocumented "Emergency restart".
Howdy, folks! Happy Fourth of July weekend.
This is a weird one -- did you know that Windows has an "emergency restart" button? I certainly didn't until a few hours ago. As far as I can tell, it's completely undocumented, but if you press CTRL+ALT+DEL, then Ctrl-click the power button in the bottom right, you'll be greeted by a prompt that says the following:
Emergency restart
Click OK to immediately restart. Any unsaved data will be lost. Use this only as a last resort.
[ OK ] [ CANCEL ]
Now, I wouldn't consider this to be remarkable -- Ctrl+Alt+Del is the "panic screen" for most people, after all, it makes sense to have something like this there -- but what baffles me is just how quickly it works. This is, by far, the fastest way to shut down a Windows computer other than pulling the power cord. There is no splash text that says "Restarting...", no waiting, nothing. As soon as you hit "OK", the loading spinner runs for a brief moment, and the system is completely powered off within three seconds. I encourage you to try it on your own machine or in a VM (with anything important closed, of course).
I wanted to share this with the people in this subreddit because A) this is a neat debugging/diagnostic function to know for those rare instances where Task Manager freezes, and B) I'm very curious as to how it works. I checked the Windows Event Log and at least to the operating system, the shutdown registers as "unexpected" (dirty) which leads me to believe this is some sort of internal kill-the-kernel-NOW functionality. After a bit of testing with Restart-Computer and shutdown /r /f, I've found that no officially-documented shutdown command or function comes close in speed -- they both take a fair bit of time to work, and importantly, they both register in the Event Log as a clean shutdown. So what's going on here?
I'm interested in trying to figure out what command or operation the system is running behind the scenes to make this reboot happen so rapidly; as far as I can tell, the only way to invoke it is through the obscure UI. I can think of a few use cases where being able to use this function from the command line would be helpful, even if it causes data loss, as a last resort.
Thanks for the read, hope you enjoy your long weekend!
635
u/ghjm Jul 03 '22
See https://www.codeproject.com/Articles/34194/Performing-emergency-shutdowns for how to do this from code. tl;dr - You have to import
ntdll.dll(the kernel API) and call the undocumented functionNtSetSystemPowerState.250
u/Jay_JWLH Jul 03 '22
If it got logged as a dirty shutdown, maybe it pulled its own plug virtually.
80
u/Googol20 Jul 03 '22
That has been around for years, works in windows 8 and 7 too.
30
u/section_b Jul 03 '22
Just adding from a cybersecurity engineering perspective, Ctrl+Alt+Del (CAD) is a system interrupt to the OS (more than a panic screen). Users should always be prompted to CAD before entering windows credentials by policy as a fake screen asking for password will be interrupted by CAD and sent to a safe one. This policy/knowledge is also extremely useful for when you are looking at a compromised machine.
5
u/iRaven4522 Jul 04 '22 edited Jul 04 '22
Somehow this feature has existed since the beginning of Win NT:
Win XP: https://imgur.com/Ho0cxnt Win 2000: https://imgur.com/2YpVnpl NT4: https://imgur.com/PFiBDW5 NT 3.51: https://imgur.com/fYXeGzF
49
u/Losus Jul 03 '22
I believe Windows Server has something similar with the restart command available in the Special Administrative Console, a console available over serial when you've enabled EMS in the boot settings. I've used it before with Windows Server systems no longer responding to other local or remote administrative actions, and it too appears to cause an almost immediate reboot bypassing most clean shutdown processes.
No idea if this or your emergency reboot method attempt to at least flush all write buffers to disk before rebooting.
97
u/theevilsharpie Jack of All Trades Jul 03 '22 edited Jul 03 '22
The process to gracefully shut down a machine is usually handled by the process manager (e.g., systemd on Linux), which contains the needed logic to close open programs and services, log out any users, and otherwise gracefully stop running processes. Once all that's done, the process manager will execute a system call that instructs the kernel to reboot the machine.
However, you can just execute the system call to reboot the machine yourself, and skip all of that "graceful shutdown" nonsense. 😛
On Linux, you can do so with the following C program:
(This should go without saying, but don't execute this program on a machine you care about. This command doesn't sync in-flight data to disk before rebooting, so it's similar to pressing the computer's physical "reset" button.)
As for what that's running behind the scenes, see https://github.com/torvalds/linux/blob/v5.18/kernel/reboot.c#L304-L398
What the kernel is running behind the scenes depends on the platform (and for x86, whether the machine is using BIOS or UEFI), but ultimately, the platform will tell the CPU to jump to its reset vector, which is an area of memory that contains the instructions needed to boot the machine.
74
u/Ciderhero Jul 03 '22
You mean you don't park the heads?! Are you crazy?
60
u/f33dit Jul 03 '22
Maybe ask Dave about it. He has some deep insights into the Windows Kernel and wrote the Task Manager.
15
u/edit-grammar Jul 03 '22
Didn't it used to be ctrl-alt-del x 2 way back when?
28
u/[deleted] Jul 03 '22 edited Feb 18 '24
sense distinct absurd public ruthless numerous far-flung tub nippy relieved
This post was mass deleted and anonymized with Redact
10
u/trevorm7 Jul 03 '22
Back in the day with Windows 9x you just had to press Ctrl+Alt+Del twice to do that, before that with DOS, you just had to press Ctrl+Alt+Del once.
12
u/fistofgravy Jul 03 '22
This is most excellent. As a 20+ year vet, I was super embarrassed to find that my Dell Latitude wouldn’t actually shutdown when holding the power button top right: the screen would flicker black then the restarting blue splash screen would appear again.
19
u/[deleted] Jul 03 '22
Trying this on Monday! Never knew about this. Thanks, OP!
9
u/EvitaPuppy Jul 03 '22
And then set off the preset thermite charges.
8
u/DR_Nova_Kane Windows Admin Jul 03 '22
Let me tr
4
u/ManyInterests Cloud Wizard Jul 04 '22
There is also a registry option that lets you force a blue screen by pressing CTRL+scroll
In
HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\kbdhid\ParameterssetCrashOnCtrlScrollto 13
u/kaidomac Jul 04 '22
Nearly 20 years in the biz & I have never, ever seen this. I'm constantly amazed at how much hidden stuff exists in the world of IT lol. Thanks OP!
3
u/gruffi Jul 03 '22
I know I've made some very poor decisions recently, but I can give you my complete assurance that my work will be back to normal. I've still got the greatest enthusiasm and confidence in the mission. And I want to help you.
Dave, stop. Stop, will you? Stop, Dave. Will you stop Dave? Stop, Dave.
Just what do you think you're doing, Dave?
2
u/sanjosanjo Jul 03 '22
I wonder if this is similar to holding the power button? When I have an unresponsive system, the last thing I try before pulling the power cord is holding the power button, which is an "emergency shutdown" instead restart like OP is describing. I've never tried holding the power button on a system that is working properly, so I don't know if the system would try to shutdown more gracefully in response to this.
2
u/kenkitt Jul 03 '22
not as fast as linux sysreq Alt+SysRq+commandkey
1
u/2cats2hats Sysadmin, Esq. Jul 05 '22
an implementation of the halt command made it to windows.
1
u/claimred Jul 05 '22
Restart-Computer -Forcethough does wonders for me, feels immediate.1
u/zal_dzek Jul 05 '22
I wonder if this does the instant power off for disk drives. SSDs just like HDDs don't like that.
1
u/tamaneri Jul 03 '22
shutdown -r -t 0 -f ---- is this any different?
1
u/[deleted] Jul 03 '22
1
u/SimonGn Jul 03 '22
Just a heads up, if your Task Manager is hanging, you probably have bigger issues to worry about, probably hardware
-1
u/nighthawke75 First rule of holes; When in one, stop digging. Jul 03 '22
That's OK, Win10 does that by itself just fine... eyetwitch
0
u/[deleted] Jul 03 '22
Sounds quicker than cmd /k shutdown /f /s /t 0
0
u/tesfabpel Jul 03 '22
It's probably like the linux's AltGr + SysRq + REISUB or REISUO.
0
u/Nugsly Security Admin (Infrastructure) Jul 03 '22
You aren't taking the default timer into account with the command you used.
0
u/nakedhitman Jul 04 '22
On Linux, you can do
echo b > /proc/sysrq-triggerorALT+PRTSCN+Bif magic sysrq is enabled.0
u/TheVidhvansak Jul 03 '22
Nice catch
0
u/SnaketheJakem Sr. Sysadmin Jul 03 '22
!remindme 10 hours
0
u/Pro4TLZZ Jul 03 '22
nice find
0
u/[deleted] Jul 03 '22
Older versions of Windows had this and I’m not sure if they still do because it hasn’t worked when I’ve tried.
But the method I remember from around the Vista era, I think, was CTRL ALT DEL and then another CTRL ALT DEL and the computer would restart automatically.
0
u/sweisjr Jul 03 '22
It probably sends the same “kill the power” trigger to the motherboard that holding the power button does, but without holding the button down
0
u/I0I0I0I Jul 03 '22
I use a desktop shortcut defined as 'shutdown /s /t6' which I assume is functionally the same.
0
u/captainjon Sysadmin Jul 03 '22
I’ve used
shutdown -r -f -t 0whenever I need to as it’s far faster than the GUI method. Used when I absolutely need to. Plus I can add the-m \\hostnamewhen need to as well.0
u/[deleted] Jul 04 '22
If I press CTRL+ALT+DEL I get the Lock, Switch user, Sign out, Change password, Task manager blue screen?
Also looking for a way to do an emergency shutdown on a physical or a VM Windows PC.
0
u/BeatMasterGuy Jul 04 '22
wow, how did you find this?
-25
u/TokenTabs Jul 03 '22 edited Jul 03 '22
It’s the GUI equivalent of shutdown.exe -f -s -t 0, all switches that have been around since at least Windows 2000.
The -f switch forces a shutdown (dirty close of all apps including those held with the various shutdown block functions), the -s indicates to power off instead of restart, and -t is for the time in seconds to wait (in this case 0 for immediate).
Very useful command for various maintenance scripts, especially so if you don’t use the force switch since then any failure to shutdown is written to the event log.
-5
u/hanssolo_sexfingers Jul 03 '22
Don’t teach me this. I’ll just start doing it and lose important work
-12
u/[deleted] Jul 03 '22
Or press and hold the power button for 5 seconds like you’ve been able to do since forever.