2
votes

Thanks to this site and others I have learned to invent a shortcut to put my Windows 10 pc to sleep. I've tried both "rundll32.exe powrprof.dll,SetSuspendState Sleep" and the same thing but with "0,1,0" instead of "Sleep". Both work fine to put my machine to sleep.

My problem is that scheduled tasks don't wake the computer when it was put to sleep with the shortcut, but do wake it if the computer was put to sleep with Start>Shut down or sign out>Sleep or Start>Power>Sleep.

Of course there is an obvious work-around: don't use the shortcut. But I would like to understand what's going on.

2

2 Answers

3
votes

The commonly used batch script command Rundll32.exe Powrprof.dll,SetSuspendState Sleep sleeps the computer in such a way that scheduled tasks are not able to wake the computer from sleep, this is due to what appears to be a bug in Rundll32.exe.

Credit goes to Techie007L's post on the microsoft forums for discovering this and proposing a solution. Instead of calling Rundll32.exe in your batch script you download an alternative tool and call that instead.

Unfortunately, after all the features it has, the Microsoft shutdown command is missing the standby feature! So, it you want to put your computer to sleep via command line, you'll need to install a more capable tool before you can use the last command above:

  1. Download Sysinternals PsTools.
  2. The download should be a ZIP file. Open it and copy PsShutdown.exe to your > desktop.
  3. On your desktop, right-click PsShutdown.exe and click Copy. Right-click it > again and click Properties.
  4. Tick Unblock and click [OK].
  5. Open File Explorer, navigate to "C:\Windows", scroll down, right-click the > system32 folder and click Paste.
  6. To enter standby, you can now use this command: psshutdown -d -t 0
2
votes

I was in the same situation and found out my problem was with the way my PC entered sleep mode. I managed to solve this by downloading PsShutdown from Microsoft, following the instructions and using the command to put my machine to sleep:

psshutdown -d -t 0

After doing this, my computer could wake up on schedule. No installation needed, just put the file anywhere and use it's path in the command line.