How to disallow USB devices to wake the computer by default in Windows 7

16

7

Every time I plug in a new mouse/keyboard or plug an existing one to a new USB port, I have to manually go to the device manager, go to the device's property page, and uncheck "Allow this device to wake the computer" on the "Power Management" page. enter image description here

Is it possible to set up a system policy in Windows 7, such that this box is not checked for new USB mice/keyboards by default?

Edit: If there's no way to set up such a system policy, is there at least a way to enumerate and disable USB wake on devices by using powercfg in a batch file?

Edit 2: This has to be possible to do at least using powercfg. powercfg devicequery wake_armed gives a list of all devices that can wake the system. Now how can I feed this list back to powercfg and have it disable the wake on the listed devices?

Duke Nukem

Posted 2013-08-14T01:43:32.993

Reputation: 865

My BOIS also does not have this option. Please let us know if you found an answer -- I've been in the habit of turning off my power supply for years, and I'd really like to change that... – Allen Pestaluky – 2015-11-28T19:41:03.030

1You can disable this in some BIOS (Legacy and UEFI) – justbrowsing – 2013-08-14T01:46:18.013

My BIOS doesn't have such an option, unfortunately. – Duke Nukem – 2013-08-14T21:14:14.207

Answers

4

Edit 2: Clarification

This answer does not solve the problem in question in its original wording. Disabling wake for all future devices does not seem to be possible. The solution in this answer only allows you to disable wake for all currently connected devices.

My original answer:

This question seems to have been answered in another SO answer

for /F "tokens=*" %%A in ('powercfg -devicequery wake_armed') do powercfg -devicedisablewake "%%A"

This needs to be run as an administrator.

Edit:

To provide a more complete solution here is a script that requests administrator privileges before running the above loop. The admin rights are requested using a Microsoft powertoy (written in VisualBasic, unsurprisingly)

@echo off
if "%~1"=="" (
  elevate %0 do
) else if "%~1"=="do" (
  for /F "tokens=*" %%A in ('powercfg -devicequery wake_armed') do (
    if not "%%A"=="NONE" (
      echo Disabling %%A
      powercfg -devicedisablewake "%%A"
    )
  )
  echo All done.
  pause
) else (
  echo Usage: %~nx0
)

SnakE

Posted 2013-08-14T01:43:32.993

Reputation: 279

This will only disable the current configuration of USB devices, not all future configurations like the question asked for. For example, run this script, then unplug a mouse and plug it back in to a new port -- the mouse will now wake from sleep again unless this script is run again for the new USB device configuration. – Allen Pestaluky – 2015-11-28T19:34:13.583

1@AllenPestaluky the question has edits which ask for at least a partial solution if the complete solution is not possible. My answer (and the answer I link to) is exactly the partial solution the OP is asking for. – SnakE – 2015-11-29T01:21:00.243

Thanks, this batch script does exactly what I wanted. I may try to find a way to automate this in the future. Would you happen to know if there's a way to do the powercfg calls through the Windows API, to avoid spawning separate processes? – Duke Nukem – 2016-06-21T04:47:36.943

1@DukeNukem No I'm not aware of such an API. I didn't do any research though so it might still exist. Also all these settings must be in the registry. So you can use the procmon powertoy to trace which registry locations are accessed by powercfg -devicequery wake_armed and write your own registry manipulation tool. – SnakE – 2016-06-23T10:58:02.127

1

To answer the questions in your edits:

No, you can not use powercfg to enumerate devices to change the default wake behaviour of all future USB configurations like you asked in your original question.

I tried using the For /F "tokens=*" %%A in ('powercfg -devicequery wake_armed') do powercfg -devicedisablewake "%%A" script, but after plugging my USB device into a new port, it defaulted back to waking the computer.

I even tried enumerating the result of powercfg -devicequery wake_from_any, but it seems that you can only enumerate connected USB devices. Even the wake_from_any argument returns a different list each time you change the port your USB device is plugged into.

To to answer your original question:

I have no idea. I really want to know the answer to this, but I still haven't found an answer. If anyone can figure this out, you will be loved dearly! <3

Allen Pestaluky

Posted 2013-08-14T01:43:32.993

Reputation: 437

1

[DISCLAIMER] This is not an answer to the OP question but rather a solution to the problem for which you probably ended up here!

Old thread but I came here firstly for a solution which I ended up resolving in another way and now I'm sharing.

[ISSUE] My issue was with an USB device (xbox controller) keeping the PC awake or waking it up as soon as it entered sleep. At first I ended up needing to do what OP was talking about, after that I was using the script posted here by SnakE.

[SOLUTION] It was solved properly without any hacky scripts or manual controls just by configuring XHCI in bios setting it from SmartAuto to Enabled.

[BITS OF WHY] What this do is forcing the USB on board controller to act as USB3 all the time rather than downgrading to USB2 and then switching to USB3 when OS takes control. Forcing it to behave proven to have solved my issue with the USB device driver misbehaving when trying to transition the PC into sleep/hibernate. Running Windows 10 which has built in drivers for USB3 enabling XHCI mode works greatly, issues my come from it if booting some OS that don't support USB3.

SmartAuto shouldn't have been an issue because (as stated here) after the first boot the controller should stay on USB3 but maybe there is a bug somewhere in it's decision making and it was behaving as Auto on my Asus motherboard.

Cody

Posted 2013-08-14T01:43:32.993

Reputation: 11

This fixed my problem with a Logitech receiver on an ASUS laptop. After this BIOS fix (I picked Disabled), I also had to turn off each device's ability to wake the computer in Device Manager again. – Jim Hunziker – 2019-12-13T12:39:47.430

-1

This seems a known issue documentation can be found here Summary:

Workaround 1 (Recommended)

Plug the USB device into an Enhanced Host Controller Interface (EHCI) host controller.

Workaround 2

Disable the USB device's ability to wake the computer. To do this, follow these steps:

Click Start
Start button
, right-click Computer, and then click Manage.
In the User Account Control dialog box, click Continue.

User Account Control permission
If you are prompted for an administrator password or for a confirmation, type the password, or click Allow.
Click Device Manager, expand Universal Serial Bus controllers, right-click the device, and then click Properties.
Click the Power Management tab, disable the Allow this device to wake the computer check box, and then click OK.

Note We recommend that you use Workaround 1 because it preserves the wake functionality. When you use Workaround 2, USB devices cannot wake the computer. Additionally, the remote control power button for a Windows Media Center IR receiver cannot wake the computer.

vfbsilva

Posted 2013-08-14T01:43:32.993

Reputation: 356

1Thanks for your answer, but the documentation you linked to is not the issue that I'm having. The steps you show in workaround 2 are exactly what I have to do every time I need to disable USB wake on a device. What I want is for this wake to be disabled by default so I don't have to do these steps every time, and I could not found any way to do that at all... – Duke Nukem – 2013-08-17T22:16:09.207