Auto Shutdown when idle

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

  1. AveYo

    AveYo MDL Expert

    Feb 10, 2009
    1,836
    5,693
    60
    #21 AveYo, Jan 28, 2020
    Last edited: Jan 28, 2020
    You are not going wrong anywhere - it's the Microsoft retards bent on breaking the task scheduler even more instead of fixing the known issues.
    It used to be enough to just add /V1 parameter to fix the /ONIDLE task to set the duration (/I), but it turns out ALL related parameters are bugged no matter if set or not.
    But no worries, I've come up with a simple workaround:
    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"
    
    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.
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  2. logicwatch

    logicwatch MDL Senior Member

    Jan 26, 2011
    289
    34
    10
    Wow so complicated
    I will give this a test thank you for all your help
    ideally once all is finally resolved I would like the time to be set for 2 hrs shutdown when idle
    so what on earth would the final powerscript be for this task to work on that figure ?
    :confused:
     
  3. AveYo

    AveYo MDL Expert

    Feb 10, 2009
    1,836
    5,693
    60
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...