I have the same problem, I was looking for everything, but did not find anything useful.
In the end, I just started messing around with various things that I could come up with. I can come up with two workarounds for our problem.
The event viewer can tell you that the completion was planned, but not when it was planned.
One idea is to ask the event viewer for the most recent shutdown of the system, the most recent scheduled shutdown, and the most recent cancellation of the scheduled shutdown. If a scheduled shutdown is later than the most recent cancellation or shutdown, then it is executed. Event IDs: 1074 to run on schedule, 1075 to cancel on schedule, in Windows / System 12 logs to start system 13 to shut down the system (all in Windows / System logs)
I was too lazy to do this in a batch file, although I know that this is possible.
Here's what I ended up doing: instead of scheduling a shutdown, just try to interrupt it. If the shutdown is not performed, an error message is displayed (Cannot interrupt the shutdown of the system because shutdown was not performed. (1116)). I think itβs much better than worrying the user when planning a shutdown.
Here is a copy of the code that I wrote for a simple automatic shutdown script, it switches between canceling and starting a scheduled shutdown.
@echo off shutdown /a if errorlevel 1 call:shutdown goto end :shutdown set /p choice=Shutdown in how many minutes? set /a mod=60 set /a mod*=%choice% shutdown /s /t %mod% :end
EDIT - I am revising this answer as I have more information to add.
The above solution will detect if a shutdown is planned using the shutdown.exe command using the / t argument.
If you need to determine if Windows has a shutdown schedule (as it happens automatically after some Windows updates), then there is a given registry entry that you can request. Below is PowerShell, but you can write a batch file to do the same.
Test-Path 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\RebootPending'
Note: this will not return true, if a reboot is planned using shutdown.exe, it will return true only if Windows indicates that your computer needs to be restarted.