0

I want my PC power-button to shut down Windows immediately. But what it actually does it prompt for action if there are e.g. unsaved changes.

How can I force the power button to shut down immediately?

I was thinking of a combination of this NirCMD command triggered by Windows Task Scheduler, but at least in the basic trigger options, I find e.g. At startup, but not At shutdown. Also, I would prefer a solution without 3rd party software like NirCMD if possible, like e.g. a native CMD-command that triggers itself on shutdown?

What to do?

2
  • use an ancient computer with AT power. Modern PCs use ATX and can't do that terrible action
    – phuclv
    Commented Mar 7, 2023 at 15:22
  • That’s a terrible idea. Every time you force shutdown, you risk corruption of data. If you really must (and I caution against it), there may be a way to rewire the switch in a desktop
    – e7eth
    Commented Jan 21 at 10:49

3 Answers 3

4

I want my PC power-button to shut down Windows immediately.

This is a bad practice as you can damage the file system.

If you need to (occasionally), you can press and hold the power button to force it off.

As a general method of operation, forcing the computer off is not a good idea.

6
  • Fully agree, of course. Further information, for the OP - When Windows goes through a "normal" shutdown, it sends a termination message to each running application, to allow that application to shut down safely. It's the applications that receive that message that display the "Unsaved Changes" dialogs when needed. That's really outside the control of Windows, as it has no way of knowing which applications might need to stop writing to disk to avoid corruption vs. which are just being "nice" and asking whether you want to not lose your work ;-). Commented Mar 7, 2023 at 13:49
  • I'm curious though, about the Nirsoft initshutdown --force mentioned in the question. It seems to me that this would have the same potential risk of filesystem and/or file corruption that a hard-power-down would. But I can't find any information on that risk. Commented Mar 7, 2023 at 13:53
  • Thanks for sharing, but anybody still interested in answering without judging: I want a (brief) press of the power-button to shut down Windows immediately.
    – Pingui
    Commented Mar 7, 2023 at 14:29
  • 1
    That can damage your filesystem which is why I say you should not do this. Damage will happen after a few such presses.
    – anon
    Commented Mar 7, 2023 at 14:31
  • 1
    @NotTheDr01ds: initshutdown --force forces applications to close without saving unsaved work, but Windows itself still shuts down normally afterwards so you should not end up with filesystem corruption. You only lose unsaved data, if there was any. It's most probably doing the same as shutdown /s /f.
    – Nassbirne
    Commented Mar 7, 2023 at 15:56
0

You are probably looking for the "Enable forced button/lid shutdown" option. It is normally hidden and you have to edit the Windows registry in order to enable it.

One way is described on tenforums.com.

In practice, you have to set the HKLM\SYSTEM\CurrentControlSet\Control\Power\PowerSettings\4f971e89-eebd-4455-a8de-9e59040e7347\833a6b62-dfa4-46d1-82f8-e09e34d029d6\Attributes DWORD to 2

0
0

Found it. It's in Advanced Settings in Power Options (not the new Windows Settings). ref: how-to-shutdown-pc-by-pressing-power-button-without-asking-confirmations

The registry change didn't help at all.

I tested it with notepad open with changes to be saved, screen locked.

See sometimes you don't have access to the monitor, GUI nor command line, and a forced shutdown from Windows is much safer then just powering off the computer. So as a last resort, ie: before the battery runs out, the power button should always do this. Common sense.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .