I found a solution on The Old New Thing . The powercfg command allows you to manage power settings, and in particular, you can use -deviceenablewake and -devicedisablewake to enable or disable the "Allow this device to wake up the computer" option.
You can see which devices are capable of doing this with this command:
powercfg -devicequery wake_from_any
You can see which devices are currently available using:
powercfg -devicequery wake_armed
Combining all this, this is a script package that I just started using to enable Wake on LAN:
powercfg -devicequery wake_from_any | findstr /i "network ethernet" >adapters.txt for /F "tokens=*" %%i in (adapters.txt) do powercfg -deviceenablewake "%%i" powercfg -devicequery wake_armed | findstr /i "network ethernet" || goto :failed
In this case, I decided to enable this option on all valid devices whose name contains the word "network" or the word "ethernet"; in some situations, of course, you may prefer to select which devices you have turned on more selectively.
source share