How to disallow USB devices to wake the computer by default in Windows 7
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
)
[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 gave SnaKe script a try.
[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 does 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 may come from forcing it if booting some OS that doesn't have support for USB3.
SmartAuto shouldn't have been an issue to start with because (as stated here) after the first bootup of the computer the controller should stay on USB3 (acting as Enabled) but maybe there is a bug somewhere in it's logic or how sleep state get's considered by the feature and it was behaving as Auto on my Asus motherboard .