I have a batch file on my Windows 11 PC that puts it to sleep. I have a hotkey on my keyboard that runs the program when I press it, putting my PC to sleep.
But recently I've run into issues where my PC will wake itself up incessantly, sometimes even seconds after I put it to sleep. I believe this to be an issue related to my ethernet controller (Intel(R) Ethernet Controller (2) I225-V). I have WoL disabled everywhere, but when I run powercfg devicequery wake_armed
in the command line, it still shows up. That is, until I found that I can also disable it in the command line using powercfg -devicedisablewake "Intel(R) Ethernet Controller (2) I225-V"
.
So this is great! Seems like the issue was solved. But I recently found out that this setting resets each time you reboot your machine. So my question is this:
Can I add a line to my batch file that puts my machine to sleep that would also disable the controller's ability to wake my PC? If this is possible, it would solve ALL of my problems that I've been troubleshooting for like a month. Greatly appreciate the help! For reference, the line of code in the batch file that puts my machine to sleep is below:
rundll32.exe powrprof.dll,SetSuspendState 0,1,0
powercfg -devicedisablewake "Intel(R) Ethernet Controller (2) I225-V"
in the batch file before therundll32.exe powrprof.dll,SetSuspendState 0,1,0
command?;
. Is that correct?;
is not correct. TrycommandA && commandB
- RuncommandA
, if it succeeds then runcommandB
. See Command Redirection, Pipes - Windows CMD - SS64.com