auto hot key bat code that puts win11 to sleep

Scott Sheridan 40 Reputation points
2026-08-18T20:43:41.6966667+00:00

want a api or dll to put my w11 PC to SLEEP, nor hibernate or power off

Windows for home | Windows 11 | Sleep and Power on, off
0 comments No comments

3 answers

Sort by: Most helpful
  1. Deleted

    This answer has been deleted due to a violation of our Code of Conduct. The answer was manually reported or identified through automated detection before action was taken. Please refer to our Code of Conduct for more information.


    Comments have been turned off. Learn more

  2. Scott Sheridan 40 Reputation points
    2026-08-19T06:59:44.89+00:00

    Here's what I wound up using in my .AHK file:

    DllCall("PowrProf\SetSuspendState", "Int", 0, "Int", 0, "Int", 0)

    Was this answer helpful?


  3. Emma1-N 11,865 Reputation points Microsoft External Staff Moderator
    2026-08-19T01:26:02.86+00:00

    Welcome Scott Sheridan,

    Thank you for reaching out to Microsoft Q&A forum. 

    Windows provides APIs and DLL functions that can place a Windows 11 PC into Sleep, Hibernate, or Shut Down mode. 

    For a batch file, one of the simplest methods is: rundll32.exe powrprof.dll,SetSuspendState 0,1,0 

    You can check this link for the information that powrprof.dll,SetSuspendState can be used to put Windows into a sleep state. How to sleep - Microsoft Q&A 

    However, on some Windows 11 systems, especially newer devices using Modern Standby (S0), this command may enter Hibernate instead of Sleep if hibernation is enabled. This behavior has been reported by Windows 11 users. Windows 11 24H2 goes into hibernation mode instead of sleep mode. How can I create a sleep mode sho… 

    To determine which sleep states your PC supports, open Command Prompt (Admin) and run:  powercfg /a 

    This will show whether the device supports: 

    • Standby (S3) (traditional sleep) 
    • Standby (S0 Low Power Idle) (Modern Standby) 
    • Hibernate 

    If the answer is helpful, please click "Yes". If you have extra questions about this answer, please click "Comment".   

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.  

    Was this answer helpful?

    0 comments No comments

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.