Auto Shutdown when idle

Discussion in 'Windows 10' started by logicwatch, Jan 26, 2020.

  1. logicwatch

    logicwatch MDL Senior Member

    Jan 26, 2011
    289
    34
    10
    Hi everyone
    I have been trying to get various computers with Windows 10 to auto shutdown when idle after a preset time.
    So far with no success. Do not want sleep or hibernate full shutdown required
    I have set up tasks in task scheduler ( does not work ) double checked settings are ok .
    I have tried several 3rd part apps and apart from 1 paid for application on trial nothing seems to work that is free ?
    I suspect its all to do with the computers on windows 10 are not ever actually running idle so the process does not kick in hence no shutdown.
    Just wondered has anybody out in MDL found a working free method to achieve this operation ?
    many thanks for any replies
    :clap3:
     
  2. kaljukass

    kaljukass MDL Guru

    Nov 26, 2012
    2,436
    883
    90
    The story you said is strange in many ways.
    If your computer has such problems, there are only two options:
    1. - There is something wrong with your computer, ie it may have damaged systems or settings or the settings are wrong.
    2. - but if you claim that the sheduled task also does not work, it could also be a mistake that this task was set incorrectly.
    If you want more detailed information, you first need to say what kind of computer it is, whether it is a desktop computer or laptop, or something else.
    It would also be interesting to know what you have tried and how.
    Also would ask for the script or commands you used to configure the sheduled task.
    Among other things, you haven't said why you are not using or, if you are using it, how do you use Windows Power Options, how have you set up Advanced Power Options?
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  3. Bat.1

    Bat.1 MDL Expert

    Oct 18, 2014
    1,095
    1,272
    60
    You did a Admin CMD of powercfg -h off ?
     
  4. logicwatch

    logicwatch MDL Senior Member

    Jan 26, 2011
    289
    34
    10
  5. logicwatch

    logicwatch MDL Senior Member

    Jan 26, 2011
    289
    34
    10
    I just used the tutorial mentioned above
     
  6. kaljukass

    kaljukass MDL Guru

    Nov 26, 2012
    2,436
    883
    90
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  7. logicwatch

    logicwatch MDL Senior Member

    Jan 26, 2011
    289
    34
    10
    ok
    this is fantastic news I assumed the tutorial I followed would be good clearly you have seen faults with it
    I have not used a script ?
    just task scheduler as set up in the tutorial
    Can you help me with steps to correct it so it will work correctly ?
     
  8. kaljukass

    kaljukass MDL Guru

    Nov 26, 2012
    2,436
    883
    90
    1. Tell, what You write instead of word "shutdown" - on picture in red box.
    task4.png
    2. what is the time when Your computer logs off users if idle?
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  9. logicwatch

    logicwatch MDL Senior Member

    Jan 26, 2011
    289
    34
    10

    1. c:\windows\system32\shutdown.exe

    2.1 hour
     
  10. kaljukass

    kaljukass MDL Guru

    Nov 26, 2012
    2,436
    883
    90
    shutdown.exe will do nothing without command line argument, ie s, r, l etc. open it with cmd.exe and they are all there
    C:\WINDOWS\system32>shutdown.exe
    Usage: shutdown.exe [/i | /l | /s | /sg | /r | /g | /a | /p | /h | /e | /o] [/hybrid] [/soft] [/fw] [/f]
    [/m \\computer][/t xxx][/d [p|u:]xx:yy [/c "comment"]]
    if You want only shut down computer, You must use this
    Code:
    %SystemRoot%\System32\shutdown.exe /f /s /t 00 if You have W10x86
    %SystemRoot%\SysWOW64\shutdown.exe /f /s /t 00 if You have W10x64
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  11. kaljukass

    kaljukass MDL Guru

    Nov 26, 2012
    2,436
    883
    90
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  12. BAU

    BAU MDL Addicted

    Feb 10, 2009
    943
    2,042
    30
    #14 BAU, Jan 26, 2020
    Last edited: Jan 28, 2020
    Enter this in a cmd/powershell/win+r..
    Code:
    powershell -c "start schtasks -arg ('/Create /RU System /NP /RL HIGHEST /F /TN ShutdownOnIdle /V1 /SC ONIDLE /I 1 /TR '+[char]34+'cmd /c timeout /T 900 && shutdown /s /hybrid /t 0 /d p:0:0'+[char]34) -verb runas"
    Triggers after 15 minutes of pc being idle (change the Interval parameter /I 15 to whatever time you need - must be in minutes, minimum of 1)

    <update:

    Change the idle duration after the timeout /T parameter - above set to 900 = 15 minutes x 60 seconds.
    - Idle detection happens every 10(5?) minutes by default if no screen saver / turn off monitor is set, so keep that in mind (substract it from the number of seconds you're gonna use for /T - for example if the display is set to power off after 2 minutes idle, then to shutdown at precisely 15 minutes you would use (15-2) x 60 = 780).

    Also added the planned parameter to the shutdown command so that it generates an information event log instead of an error.

    I have tested this workaround on Pro v1903 and it works as expected: as soon as PC enters idle mode, cmd starts counting down then shuts down. If interrupting the idle mode before the count down finishes, shutdown is aborted. I see no reason why it would not work on all Windows 10 versions.
    :update>

    Took liberty to add /hybrid parameter since it does help speed up cold boots on uefi afterwards.
    Rather strange request, since this will discard any unsaved work across all logged on accounts!
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  13. logicwatch

    logicwatch MDL Senior Member

    Jan 26, 2011
    289
    34
    10
    Hi
    thanks for this

    powershell -c "start schtasks -arg ('/Create /RU System /NP /RL HIGHEST /F /TN ShutdownOnIdle /SC ONIDLE /I 15 /TR '+[char]34+'shutdown /s /hybrid /t 0'+[char]34) -verb runas"

    if I ever wanted to remove it completely in the future what command would then be required ?
    regards
    ;)
     
  14. kaljukass

    kaljukass MDL Guru

    Nov 26, 2012
    2,436
    883
    90
    #16 kaljukass, Jan 27, 2020
    Last edited: Jan 27, 2020
    You don't need any script or command, just open Task Scheduler Manager and edit or delete it.
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  15. logicwatch

    logicwatch MDL Senior Member

    Jan 26, 2011
    289
    34
    10
    ok thanks will give it a try now as so far nothing has worked ?
     
  16. BAU

    BAU MDL Addicted

    Feb 10, 2009
    943
    2,042
    30
    Code:
    powershell -c "start schtasks -arg '/Delete /F /TN ShutdownOnIdle' -verb runas"
    Task being set to run for system account means it will absolutely run and be able to force shutdown the PC on idle.
    But some PCs might never enter idle mode due to various reasons such as downloading / seeding torrents, media players running, other users logged on via network, windows updates/telemetry/maintenance hanging, shutdown.exe tool missing (deleted/blocked), or even optical mouse or other controllers placed incorrectly or natively "drifting" (for that there are solutions such as disabling wake up in mouse power options and deploying a screensaver that ignores small mouse movements).
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  17. logicwatch

    logicwatch MDL Senior Member

    Jan 26, 2011
    289
    34
    10
    #19 logicwatch, Jan 27, 2020
    Last edited: Jan 27, 2020
    (OP)
    ok
    we have made progress at last we get a shutdown after using the script in powershell
    will continue testing and changing the shutdown times
    many thanks
    will report back !!
    :)
     
  18. logicwatch

    logicwatch MDL Senior Member

    Jan 26, 2011
    289
    34
    10
    update
    well shutdown now always works !
    but strangely no matter whatever I set the shutdown time to it always shuts down after 10mins ??
    I have looked in the settings within task scheduler and say I have set the time for 30 mins using the powershell script the time is set correctly for 30mins in task scheduler but the computer ignores this and shuts down everytime after only 10 mins ??
    where am I going wrong ??
    :(