Desktop shortcut to tell computer to sleep in 25 minutes


  1. Posts : 2
    Windows 7 Professional 64 Bit
       #1

    Desktop shortcut to tell computer to sleep in 25 minutes


    How to force sleep/force shut down a laptop after X time no matter what

    I am having trouble getting the sleep command to work
    https://i.imgur.com/YbEorGz.png

    Also where do I put the time? Shouldn't there be an XX or 00 like in the shutdown command? Is what I am typing into cmd prompt wrong?
      My Computer


  2. Posts : 721
    Windows 10, Windows 8.1 Pro, Windows 7 Professional, OS X El Capitan
       #2

    Hello LongApple,

    Firstly, it's 'rundll32.exe'. Not 'rund1132.exe'.

    Secondly...

    LongApple said:
    I am having trouble getting the sleep command to work[.] Also where do I put the time? Shouldn't there be an XX or 00 like in the shutdown command? Is what I am typing into cmd prompt wrong?
    Rundll32 is not a command. It is a wrapper program that's purpose is to launch other programs stored within dll files and should never be invoked by the user directly; not through the command prompt, not through shourtcuts.

    Forcing Windows to sleep using this method is considered dangerous.


    You should instead be using "Control Panel\Hardware and Sound\Power Options\Edit Plan Settings" to choose when your computer sleeps.

    Desktop shortcut to tell computer to sleep in 25 minutes-poweroptions1.jpeg
    Desktop shortcut to tell computer to sleep in 25 minutes-poweroptions2.jpeg


    If you really want your computer to sleep through a shortcut/command, it's recommended you download PsShutdown from here and create a shortcut to that instead.
      My Computer


  3. Posts : 6,285
    Windows 10 Pro X64
       #3

    Not sure why this would be dangerous. I just tried it and it worked fine.

    rundll32.exe powrprof.dll,SetSuspendState 0,1,1


    Would need to put this in a batch file, something like:

    timeout 1800
    rundll32.exe powrprof.dll,SetSuspendState 0,1,1


    >timeout /?

    TIMEOUT [/T] timeout [/NOBREAK]

    Description:
    This utility accepts a timeout parameter to wait for the specified
    time period (in seconds) or until any key is pressed. It also
    accepts a parameter to ignore the key press.

    Parameter List:
    /T timeout Specifies the number of seconds to wait.
    Valid range is -1 to 99999 seconds.

    /NOBREAK Ignore key presses and wait specified time.

    /? Displays this help message.

    NOTE: A timeout value of -1 means to wait indefinitely for a key press.

    Examples:
    TIMEOUT /?
    TIMEOUT /T 10
    TIMEOUT /T 300 /NOBREAK
    TIMEOUT /T -1
      My Computer


  4. Posts : 721
    Windows 10, Windows 8.1 Pro, Windows 7 Professional, OS X El Capitan
       #4

    A quote from a user at Superuser.com briefly describes Rundll32s problems by invoking Rundll32 this way.

    windows 7 - What is the command to use to put your computer to sleep (not hibernate)? - Super User

    accolade said:
    rundll32.exe PowrProf.dll,SetSuspendState is not recommended. It is dangerous. (Because it corrupts the stack, as it does not comply with the function signature demanded by Rundll32. Then unforeseeable bad things may happen, as Raymond Chen warns…)
    Also see Michaels post How to use Rundll32 to execute DLL Function? - Stack Overflow

    Michael said:
    Rundll32 only supports running DLL exports with the following signature:
    void CALLBACK EntryPoint(HWND hwnd, HINSTANCE hinst, LPSTR lpszCmdLine, int nCmdShow);It does not support running arbitrary entry points. Since ShellExecute does not have that signature, clearly bad things will happen.
    INFO: Windows Rundll and Rundll32 Interface has more info on the rundll32 interface.
    If you want to do the equivelent of ShellExecute from the command line, just use start:
    C:\>start "C:\Documents and Settings\admin\Desktop\tmp"
      My Computer


  5. Posts : 6,285
    Windows 10 Pro X64
       #5

    Does that warning apply in this case? It did not cause me any harm and I ran it several times.

    For completeness:

    The command I gave, rundll32.exe powrprof.dll,SetSuspendState 0,1,1, suspends the computer.

    This one, Rundll32.exe Powrprof.dll,SetSuspendState Sleep, puts it to sleep.
      My Computer


 

  Related Discussions
Our Sites
Site Links
About Us
Windows 7 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 7" and related materials are trademarks of Microsoft Corp.

© Designer Media Ltd
All times are GMT -5. The time now is 09:31.
Find Us