15

Sometimes when I bump my mouse or my keyboard my computer turns on. How do I prevent that?

9999years
  • 2,619

4 Answers4

27

You can disable all devices from waking your computer with powershell -Command "powercfg /devicequery wake_armed | ForEach{ powercfg /devicedisablewake $_ }".

In cmd, you can run powercfg /devicequery wake_armed to get a list of the devices that are currently allowed to wake up your computer. Chances are you’ll see a couple HIDs (human interface device) and maybe a network card. You can copy/paste these into the corresponding command, powercfg /devicedisablewake "your device here", but that’s annoying.

The ForEach{ $_ } operates a bit like xargs if you’re familiar with that, where $_ is a placeholder for the text in each line of the input (i.e. the powercfg /devicequery wake_armed before the pipe).

9999years
  • 2,619
2

Possible solution below

This did not work for many users, including me:

powercfg /devicedisablewake "your device here"

There was some kind of admin rights problem even though we all ran the command line as administrators. Just did a search about this through the web today and there is massive amount of unresolved queries about it. Well, I think I might have resolved it. I had exactly opposite problem that the first question suggested, my device was actually preventing sleep of my monitor. So I did two things and at least one of them helped me:

A) I installed an old driver for the device that was causing problems (Genius MaxFire Blaze 5 gamepad controller) instead of the default one (MS driver for Xbox 360 controller from 2019 I think). Well, at least I tried to. I had to resort to updating it by "have disk" and manually pushing the old drivers to the system after I found them installed in the system.

EDIT: it WAS a driver issue after all. The old gamepad driver was uninstalled after machine restart (because I installed the new one instead) and it broke the monitor sleep again. So I installed it back and hopefully I will never have this issue again. The old driver is from 2009, the new one is from 2019. "Good job", Microsoft!

B) at the same time I made a small hack file called disable_wake_gamepad.cmd, it's name does not matter. The content was the exact line that was not working for me in the shell:

powercfg /devicedisablewake "HID-compliant game controller"

Next I have opened group policy editor gpedit.msc and navigated to User Configuration > Windows Settings > Scripts > Logon and added my little script by the Add button. Then I restarted machine because the script runs at logon (presumably under System credentials).

And I think this helped. I tried to reinstall back the newest MS driver for the gamepad and it did install back and the gamepad is STILL NOT blocking the monitor sleep, so success - after 2 days of research and testing various things.

* Note: HID-compliant game controller was the device name from the list (powercfg devicequery wake_armed) of wake_armed devices. I knew it's the gamepad that caused problems because when I disconnected it, the monitor was able to sleep**.

** It's easy to test monitor sleep quickly by using a small utility like for example DisplayPowerOff4.1 or the Nirsoft utility.

I will keep testing this and will update this post if I find out what exactly helped. But you guys now have good leads now. Good luck, you will need it. FYI this gamepad was FINE with my monitor under Win7, it's Microsoft Windows 10 that broke it.

Tyler
  • 141
1

When you want to disable it only for the mouse and keyboard do this:

  1. Open the Device Manager
  2. Navigate to Keyboards
  3. Select and default/ using keyboard (usually Standard PS/2 Keyboard), right-click and go to properties
  4. Tap Power-Management and uncheck “Allow this device to wake the computer”: enter image description here

Same steps for the mouse!

Note: This does not work on every device, on laptops there maybe you have to go to the Power Options!

1

Try this in powershell-

$Powercfg = "Powercfg.exe"
& $Powercfg '/Devicequery', 'Wake_Armed' | % { & $Powercfg '/DeviceDisableWake' $_ *> $Null }
Roni Ked
  • 21
  • 5