Putting a PC to sleep from a batch
Posted: 22 Feb 2016 17:32
Command shutdown doesn't offer sleep option. If Hibernation is disabled, shutdown /h may not go to pure sleep mode either. On the web there're suggestions to use the following command for sleep if Hibernation is disabled:
However, several authors pointed that using Rundll32.exe to call random functions is inappropriate and may harm Windows install. Besides that, any parameters after SetSuspendState are said to be ignored by rundll32.exe, and the only affecting parameter is whether Hibernation is set On or Off. Others mentioned stand alone programs to call from a batch to enter Sleep mode, including Powershell and VBS samples.
Can someone provide a batch code sample putting PC to sleep without invoking rundll32.exe and other outside programs or programming languages?
Code: Select all
%windir%\system32\rundll32.exe PowrProf.dll, SetSuspendState 0,1,0
However, several authors pointed that using Rundll32.exe to call random functions is inappropriate and may harm Windows install. Besides that, any parameters after SetSuspendState are said to be ignored by rundll32.exe, and the only affecting parameter is whether Hibernation is set On or Off. Others mentioned stand alone programs to call from a batch to enter Sleep mode, including Powershell and VBS samples.
Can someone provide a batch code sample putting PC to sleep without invoking rundll32.exe and other outside programs or programming languages?