0

So I have scheduled a task to run some script at windows shutdown through task scheduler, the trigger is an event its source is USER32 its ID is 1074. I have made some shortcut placed on my desktop to shutdown my computer its code is:

shutdown /s

the problem is whenever I try to shutdown my computer using this shortcut the scheduled script run as expected. But whenever I try to shutdown using the normal way (start > shutdown), the scheduled script doesn't run as expected. when viewing event log the case of the shortcut its says EXPLORER.exe initiated a shutdown, the case of the normal method says C:\Windows\system32\shutdown.exe initiated a shutdown. I don't know why the script doesn't run as expected when I shutdown using the normal way. Ps: the scheduled scripts does copy the estimated charge remaining in the battery and shutdown time to some text file placed in my desktop.

3
  • If you don't provide a time, then 30 seconds is assumed, I am going to guess you don't want any delay. If that is the case then you should be using shutdown /s /f /t 0 or simply shutdown /s /t 0 instead of the command your using. You might want to force the shutdown, this will close any open applications forcefully, so I suggest you test without it. Proper research is the key to solving any problem.
    – Ramhound
    Commented Oct 31, 2017 at 20:54
  • Exactly!!! and part of that research is asking questions in the right place Commented Oct 31, 2017 at 22:25
  • You can’t use shutdown to shutdown a system that is already shutting down. You’ll just be told the system is already shutting down. You do understand that using a trigger based on the system shutting down to run the shutdown command really makes no sense, right? What are you REALLY trying to accomplish here? Commented Nov 1, 2017 at 2:22

0

You must log in to answer this question.

Browse other questions tagged .