Solved Can't get a daily Shutdown working in Task Scheduler...


Local time
10:25 PM
Posts
39
OS
Windows
Similar issue to Can't get a daily Shutdown working in Task Scheduler... - Except ...

This used to work.

I want the computer to shut down at 8:30 P.M. on Monday and Thursday only.

From the other thread:
- S0 is not supported by firmware.
- The computer intentionally never enters sleep modes. (the only allowed one is sleep after 10 minutes of inactivity on battery).
- I originally had the task set to shutdown running "shutdown.exe /s /t /0 /f" I changed it to use an AutoHotKey command.
- Other scheduled tasks work fine.
- Shutdown scheduled task works fine if I click Run on it from the Task Scheduler.
- Shutdown scheduled task previously worked fine from Task Scheduler.
- Shutdown scheduled task does not work on a timer from Task Scheduler - i.e. I set the task to shut down the computer 5 minutes from now, walk away from the computer and 10 minutes later it is still running.

I would be open to other (free) software, but I don't have full admin rights on the machine, and I want something that could run from the command line. I downloaded Wise Auto Shutdown, and I can run it, but it looks like I need to open the program and select start task so it would run. I don't want to have to do that two days each week. It may be possible to run it via command line options, but I didn't see that in the documentation.
 
Windows Build/Version
23H2 22631.5335

My Computer

System One

  • OS
    Windows
Tested on a VM, worked fine without running the task manually.
How do you have the task configured?

Also command should be 'shutdown' for program name and args /s /f /t 0 (not /0)
 

My Computer

System One

  • OS
    Linux Mint
    Computer type
    Laptop
    Manufacturer/Model
    System76 Lemur Pro
I only want it to run at 8:30, but I added extra times to check if it worked, it doesn't.
Above might be an issue, I had it previously set for 5-minutes of idle (when it used to work) and I reduced it to 1 minute when it stopped working, but it didn't help.
I probably did have "0" and not "/0" when it was using the shutdown.exe trigger. As I said, both tasks work fine when I click Run from Task Scheduler.
 

My Computer

System One

  • OS
    Windows
More info:

I tried ShutdownWithUpdates - same results. It works fine from the command line or when run manually from Task Scheduler, but does not run at the scheduled time.

The thing that I'm confused on is why Task Scheduler works for some tasks - Running Access database reports, etc., but fails for shutdown tasks, even running an AutoHotKey Script. How would it know what the script does to avoid it running ...
 

My Computer

System One

  • OS
    Windows
Are you by chance trying to run it "whether user is logged in or not"?
 

My Computer

System One

  • OS
    Linux Mint
    Computer type
    Laptop
    Manufacturer/Model
    System76 Lemur Pro
Works fine for me. Are you making sure to run with highest privileges?

Image1.webp
 

My Computers

System One System Two

  • OS
    Win11 Pro 25H2 (RTM+)
    Computer type
    PC/Desktop
    Manufacturer/Model
    Acemagic
    CPU
    Intel i7-14650HX
    Memory
    32 GB
    Graphics Card(s)
    No GPU - Built-in Intel Graphics
    Sound Card
    Integrated
    Monitor(s) Displays
    Varies as machine will often be moved to locations with different monitors
    Screen Resolution
    Varies
    Hard Drives
    1 x 1TB Gen 4 NVMe SSD
    PSU
    120W Power Brick
    Keyboard
    Corsair K70 Max RGB Magnetic Keyboard
    Mouse
    Logitech MX Master 3
    Internet Speed
    1Gb Up / 1 Gb Down
    Browser
    Edge
    Antivirus
    Windows Defender
  • Operating System
    Win11 Pro 25H2 (RTM+)
    Computer type
    Laptop
    Manufacturer/Model
    Lenovo ThinkBook 13x Gen 2
    CPU
    Intel i7-1255U
    Memory
    16 GB
    Graphics card(s)
    Intel Iris Xe Graphics
    Sound Card
    Realtek® ALC3306-CG codec
    Monitor(s) Displays
    13.3-inch IPS Display
    Screen Resolution
    WQXGA (2560 x 1600)
    Hard Drives
    2 TB 4 x 4 NVMe SSD
    PSU
    USB-C / Thunderbolt 4 Power / Charging
    Keyboard
    Backlit, spill resistant keyboard
    Mouse
    Buttonless Glass Precision Touchpad
    Internet Speed
    1Gb Up / 1Gb Down
    Browser
    Edge
    Antivirus
    Windows Defender
    Other Info
    WiFi 6e / Bluetooth 5.1 / Facial Recognition / Fingerprint Sensor / ToF (Time of Flight) Human Presence Sensor
OP stated he doesn't have admin rights.

If the answer is you're trying to run 'whether user is logged on or not' then your user needs to have the 'log on as batch job' user right assignment
 

My Computer

System One

  • OS
    Linux Mint
    Computer type
    Laptop
    Manufacturer/Model
    System76 Lemur Pro

My Computer

System One

  • OS
    Windows 11 Pro 25H2
    Computer type
    PC/Desktop
    Manufacturer/Model
    Intel NUC12WSHi7
    CPU
    12th Gen Core i7-1260P
    Motherboard
    NUC12WSBi7
    Memory
    64 GB Micron PC4-25600
    Graphics Card(s)
    Intel Iris Xe Graphics
    Sound Card
    on-board Realtek HD Audio
    Monitor(s) Displays
    Dell U3219Q
    Screen Resolution
    3840 x 2160
    Hard Drives
    Samsung SSD 990 PRO 1TB
    Crucial MX500 2 TB
    Antivirus
    Microsoft Defender
Solved - sortof ...

I compared my screenshots to @neemobeer's screenshots. Under Conditions, I had "Start the task only if the computer is idle for 1 minute." I unchecked that and it worked perfectly.

(I'm not crazy about that, b/c if one of my other tasks is running and takes longer than planned, the Task Scheduler will shut it down in the middle of it.").

Apparently, SOMETHING is always running in the background to make Windows think the computer is always busy.

To answer some of the other questions:

Run whether user is logged in or not has never worked for us. I wish it would, but when I tried it, it didn't seem to work.

Oddly, Run with highest privileges didn't seem to work either. I tried with some of the other tasks and they did not work with that selected and did work with that unselected - seems odd, but ... (Then again, when I tried that, I only had user rights. Currently, I have elevated rights, but I do not have admin rights.)
 

My Computer

System One

  • OS
    Windows
OP stated he doesn't have admin rights.
Doesn't matter - another user account with admin rights can be used, that is, unless they have no access to such an account at all.

It's also possible that this may not be necessary. It's how I set it up and it worked perfectly for me.
 

My Computers

System One System Two

  • OS
    Win11 Pro 25H2 (RTM+)
    Computer type
    PC/Desktop
    Manufacturer/Model
    Acemagic
    CPU
    Intel i7-14650HX
    Memory
    32 GB
    Graphics Card(s)
    No GPU - Built-in Intel Graphics
    Sound Card
    Integrated
    Monitor(s) Displays
    Varies as machine will often be moved to locations with different monitors
    Screen Resolution
    Varies
    Hard Drives
    1 x 1TB Gen 4 NVMe SSD
    PSU
    120W Power Brick
    Keyboard
    Corsair K70 Max RGB Magnetic Keyboard
    Mouse
    Logitech MX Master 3
    Internet Speed
    1Gb Up / 1 Gb Down
    Browser
    Edge
    Antivirus
    Windows Defender
  • Operating System
    Win11 Pro 25H2 (RTM+)
    Computer type
    Laptop
    Manufacturer/Model
    Lenovo ThinkBook 13x Gen 2
    CPU
    Intel i7-1255U
    Memory
    16 GB
    Graphics card(s)
    Intel Iris Xe Graphics
    Sound Card
    Realtek® ALC3306-CG codec
    Monitor(s) Displays
    13.3-inch IPS Display
    Screen Resolution
    WQXGA (2560 x 1600)
    Hard Drives
    2 TB 4 x 4 NVMe SSD
    PSU
    USB-C / Thunderbolt 4 Power / Charging
    Keyboard
    Backlit, spill resistant keyboard
    Mouse
    Buttonless Glass Precision Touchpad
    Internet Speed
    1Gb Up / 1Gb Down
    Browser
    Edge
    Antivirus
    Windows Defender
    Other Info
    WiFi 6e / Bluetooth 5.1 / Facial Recognition / Fingerprint Sensor / ToF (Time of Flight) Human Presence Sensor
Another thought - You might also try the sysinternals PSSHUTDOWN utility. I use it to reboot or shutdown all my systems from remote PCs over the network but it works equally well locally.

PsShutdown
 

My Computers

System One System Two

  • OS
    Win11 Pro 25H2 (RTM+)
    Computer type
    PC/Desktop
    Manufacturer/Model
    Acemagic
    CPU
    Intel i7-14650HX
    Memory
    32 GB
    Graphics Card(s)
    No GPU - Built-in Intel Graphics
    Sound Card
    Integrated
    Monitor(s) Displays
    Varies as machine will often be moved to locations with different monitors
    Screen Resolution
    Varies
    Hard Drives
    1 x 1TB Gen 4 NVMe SSD
    PSU
    120W Power Brick
    Keyboard
    Corsair K70 Max RGB Magnetic Keyboard
    Mouse
    Logitech MX Master 3
    Internet Speed
    1Gb Up / 1 Gb Down
    Browser
    Edge
    Antivirus
    Windows Defender
  • Operating System
    Win11 Pro 25H2 (RTM+)
    Computer type
    Laptop
    Manufacturer/Model
    Lenovo ThinkBook 13x Gen 2
    CPU
    Intel i7-1255U
    Memory
    16 GB
    Graphics card(s)
    Intel Iris Xe Graphics
    Sound Card
    Realtek® ALC3306-CG codec
    Monitor(s) Displays
    13.3-inch IPS Display
    Screen Resolution
    WQXGA (2560 x 1600)
    Hard Drives
    2 TB 4 x 4 NVMe SSD
    PSU
    USB-C / Thunderbolt 4 Power / Charging
    Keyboard
    Backlit, spill resistant keyboard
    Mouse
    Buttonless Glass Precision Touchpad
    Internet Speed
    1Gb Up / 1Gb Down
    Browser
    Edge
    Antivirus
    Windows Defender
    Other Info
    WiFi 6e / Bluetooth 5.1 / Facial Recognition / Fingerprint Sensor / ToF (Time of Flight) Human Presence Sensor
I'm marking this as solved, since the original question was solved. I still would like to know what Task Scheduler uses to determine if the system is idle and how I can change this - i.e. apparently now it thinks it is never idle. I would like to have it shut down only if it isn't actively processing a task. Then again, none of the other options I tested had a way to disable shutdown if the computer was not idle, unless AutoHotKey has a way of determining that.
 

My Computer

System One

  • OS
    Windows
The issue doesn't appear to be with shutting down the computer - AutoHotKey, Shutdown.exe, ShutdownWithUpdates.exe all appear to do that when run manually or manually from Task Scheduler. The issue appears to be that Task Scheduler thinks the computer is not idle, even if I set it to only need the system to be idle for 1 minute and wait 2 hours for the idle state to kick in.

Maybe I have the opposite issue from the thread that I originally linked to - i.e. his computer wouldn't shut down if it was asleep/idle. Mine is never set to go to sleep/idle, so perhaps windows thinks it is always active.

I checked the power plan settings, and I don't appear to be able to set the computer to go to sleep when plugged in. It is set to "Never" and grayed out and it says "Some settings are managed by your system administrator."
 

My Computer

System One

  • OS
    Windows
The issue doesn't appear to be with shutting down the computer - AutoHotKey, Shutdown.exe, ShutdownWithUpdates.exe all appear to do that when run manually or manually from Task Scheduler. The issue appears to be that Task Scheduler thinks the computer is not idle, even if I set it to only need the system to be idle for 1 minute and wait 2 hours for the idle state to kick in.

Maybe I have the opposite issue from the thread that I originally linked to - i.e. his computer wouldn't shut down if it was asleep/idle. Mine is never set to go to sleep/idle, so perhaps windows thinks it is always active.

I checked the power plan settings, and I don't appear to be able to set the computer to go to sleep when plugged in. It is set to "Never" and grayed out and it says "Some settings are managed by your system administrator."

That would be a Group Policy. You may have something set in there that is influencing your shutdown.

Just spitballin' here: It's also possible that MS accomplishes "never sleep" through some sort of periodic ping that makes the "sleep check" module think the user is still active. That would be in lieu of the sleep-check module just (properly) checking the switch that says "don't sleep, ever". The result being the Task Manager is seeing that ping as activity whereas the interactive request is just going with your command and gittin' 'er done.

I've seen worse code kludges that were there because they were layered on other kludges that were making things work without rewriting a whole subsystem. Not that I ever coded anything like that back in the day. Nope.
 

My Computer

System One

  • OS
    Windows 11 Pro 24H2
    Computer type
    Laptop
    Manufacturer/Model
    HP
    CPU
    Intel Ultra 7 155H
    Memory
    16gb
    Graphics Card(s)
    Intel Arc integrated
    Hard Drives
    SSD
I still would like to know what Task Scheduler uses to determine if the system is idle and how I can change this - i.e. apparently now it thinks it is never idle.
Probably still works like this, or similar…

“In Windows 7, the Task Scheduler verifies that the computer is in an idle state every 15 minutes. Task Scheduler checks for an idle state using two criteria: user absence, and a lack of resource consumption. The user is considered absent if there is no keyboard or mouse input during this period of time. The computer is considered idle if all the processors and all the disks were idle for more than 90% of the last detection interval. (An exception would be for any presentation type application that sets the ES_DISPLAY_REQUIRED flag. This flag forces Task Schedule to not consider the system as being idle, regardless of user activity or resource consumption.)”

Edit, for additional info


 

My Computer

System One

  • OS
    Windows 11 Pro 25H2
    Computer type
    PC/Desktop
    Manufacturer/Model
    Intel NUC12WSHi7
    CPU
    12th Gen Core i7-1260P
    Motherboard
    NUC12WSBi7
    Memory
    64 GB Micron PC4-25600
    Graphics Card(s)
    Intel Iris Xe Graphics
    Sound Card
    on-board Realtek HD Audio
    Monitor(s) Displays
    Dell U3219Q
    Screen Resolution
    3840 x 2160
    Hard Drives
    Samsung SSD 990 PRO 1TB
    Crucial MX500 2 TB
    Antivirus
    Microsoft Defender
@pseymour - Thank you that helps. A couple of things leap out at me:

  • First, it only checks every 15 minutes and considers it idle if nothing happened for 90% of the last 15 minutes. So my testing where I set the task to shutdown in 3 minutes from now, could NEVER work. (Although it also didn't work at the regular time with the 2 hour wait for idle, so probably something else was happening).
  • Second, whatever program might have sent an ES_DISPLAY_REQUIRED flag would prevent it also - and that is likely a program that I don't have access to in order to prevent.
I think I'm going to live without checking for the idle state, but I think I will remove the "/f" (Force) flag, which should allow it to shutdown gracefully. (And I'll live with it if if occasionally fails due to a running program.
 

My Computer

System One

  • OS
    Windows
Minor update.

The computer failed to shut down Thursday night. There was a driver waiting for confirmation to be installed, but that wasn't the issue:
  • I checked the history for the script and it said it ran successfully, but it gave me a message which I looked up which basically said "The shutdown command cannot be executed without the -force option when the computer is in locked mode."
  • Apparently, the computer considers "Sent the command" as successful, whether or not it actually worked. So all my settings for retry every 5 minutes got ignored in this case.
I re-enabled the /f option and it shutdown, but it wasn't in locked mode. Hopefully it will work tonight.
 

My Computer

System One

  • OS
    Windows
Back
Top Bottom