0

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

7
  • Have you tried putting the powercfg -devicedisablewake "Intel(R) Ethernet Controller (2) I225-V" in the batch file before the rundll32.exe powrprof.dll,SetSuspendState 0,1,0 command?
    – DavidPostill
    Commented Jun 15 at 17:49
  • I did but it's possible I did it incorrectly. It just didn't put my PC to sleep when I tried to run it. I'm not super familiar with how batch files work when running multiple processes but I tried separating the 2 commands with a ;. Is that correct? Commented Jun 15 at 18:41
  • 1
    ; is not correct. Try commandA && commandB - Run commandA, if it succeeds then run commandB. See Command Redirection, Pipes - Windows CMD - SS64.com
    – DavidPostill
    Commented Jun 15 at 19:43
  • That didn't seem to work. But it may have worked by simply putting each command on a different line? Does that make sense? EDIT: Putting each command on a different line did not work, while it did end up putting my machine to sleep, it did not remove the Ethernet Controller from the wake devices. Commented Jun 16 at 15:53
  • Had a thought, could it be failing when I use && because the first command (being the removal of the controller from the wake devices) can only be run by an admin? And running the batch file doesn't run as an admin? Commented Jun 16 at 19:16

0

You must log in to answer this question.

Browse other questions tagged .