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


Local time
1:48 AM
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 My Computer

At a glance

Windows
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 My Computer

At a glance

Linux Mint
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 My Computer

At a glance

Windows
OS
Windows
I don't seem to be able to upload images ... Will try something else ...
 

My Computer My Computer

At a glance

Windows
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 My Computer

At a glance

Windows
OS
Windows
1748975950719.webp
1748976007608.webp
1748976051718.webp
1748976074362.webp
 

My Computer My Computer

At a glance

Linux Mint
OS
Linux Mint
Computer type
Laptop
Manufacturer/Model
System76 Lemur Pro
Are you by chance trying to run it "whether user is logged in or not"?
 

My Computer My Computer

At a glance

Linux Mint
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 My Computers

  • At a glance

    Win11 Pro 25H2 (RTM+)Intel i7-14650HX32 GBNo GPU - Built-in Intel Graphics
    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
  • At a glance

    Win11 Pro 25H2 (RTM+)Intel i7-1255U16 GBIntel Iris Xe Graphics
    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 My Computer

At a glance

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

My Computer My Computer

At a glance

Windows 11 Enterprise 25H2 [rev. 8893]
OS
Windows 11 Enterprise 25H2 [rev. 8893]
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 My Computer

At a glance

Windows
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 My Computers

  • At a glance

    Win11 Pro 25H2 (RTM+)Intel i7-14650HX32 GBNo GPU - Built-in Intel Graphics
    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
  • At a glance

    Win11 Pro 25H2 (RTM+)Intel i7-1255U16 GBIntel Iris Xe Graphics
    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 My Computers

  • At a glance

    Win11 Pro 25H2 (RTM+)Intel i7-14650HX32 GBNo GPU - Built-in Intel Graphics
    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
  • At a glance

    Win11 Pro 25H2 (RTM+)Intel i7-1255U16 GBIntel Iris Xe Graphics
    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 My Computer

At a glance

Windows
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 My Computer

At a glance

Windows
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 My Computer

At a glance

Windows 11 Pro 24H2Intel Ultra 7 155H16gbIntel Arc integrated
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 My Computer

At a glance

Windows 11 Enterprise 25H2 [rev. 8893]
OS
Windows 11 Enterprise 25H2 [rev. 8893]
@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 My Computer

At a glance

Windows
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 My Computer

At a glance

Windows
OS
Windows
Back
Top Bottom