How to sleep windows 10 device RRS feed

  • Question

  • Hi 

    I need to do my windows 10 device into sleep mode. Currently I am doing this by using below code-

      string filename = "Rundll32.exe";

      string arguments = "powrprof.dll, SetSuspendState 0,1,1";

           if (!string.IsNullOrWhiteSpace(filename) && !string.IsNullOrWhiteSpace(arguments))
                    ProcessStartInfo startinfo = new ProcessStartInfo(filename, arguments);

    Actually I need to wake up this system after few hours after sleeping through scheduler, but not waking up.

    BUT if I sleep it manually it wakes up the system on time through scheduler.

    So I want to know the code which runs on manually sleep. Need to use same code instead of above.

    sandeep chauhan

    Monday, January 28, 2019 11:25 AM

All replies

  • Hi,

    According to https://docs.microsoft.com/zh-cn/windows/desktop/api/powrprof/nf-powrprof-setsuspendstate. And pay attention to The third parameter of SetSuspendState(). 

    • If this parameter is TRUE, the system disables all wake events. If the parameter is FALSE, any system wake events remain enabled.

    You have set it to true and disables all wake events.

    Best regards,


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Wednesday, January 30, 2019 6:50 AM
  • Hi Drake

    Yes I was doing same made it false but same issue.

    But now I resolve my issue as I mentioned into my question that "when I sleep it manually it was waking up through scheduler" So I sleep it manually by using below code and now its working fine for me.

     private static void SleepDevice()
                var inputSim = new InputSimulator();
                inputSim.Keyboard.ModifiedKeyStroke(VirtualKeyCode.LWIN, VirtualKeyCode.VK_X);

    sandeep chauhan

    Wednesday, January 30, 2019 8:31 AM