0

I'm currently making a program to schedule computer shutdowns or reboots. You input hours, minutes and seconds and then the computer shuts down/restarts after that given time. A red text then pops-up telling the remaining time before it shuts down. However, if I close the program and reopen it, the shutdown is still scheduled and I'd like to show the remaining time and inform the user. Is there any way to check if a scheduled shutdown is running ? I'll later make my program write to a log file each shutdown date and duration so I can get the remaining time before it stops. This is how I stop the computer:

Process.Start("shutdown.exe", "/s /f /t " + seconds);
BartoszKP
  • 34,786
  • 15
  • 102
  • 130
JiggyJinjo
  • 197
  • 1
  • 11
  • 2
    This type of program would be better suited as a service (with a seperate GUI application to configure). Seems like you're re-inventing windows scheduled tasks but there are already libraries available you could use. – webnoob Feb 17 '17 at 10:33
  • My program is for education purposes/learning while still remaining useful for me. Here's how it looks : https://puu.sh/u76s3/ae4a889fcf.png. I would like to do it from scratch without any other help – JiggyJinjo Feb 17 '17 at 10:40
  • Look for a "shutdown.exe" process? – IS4 Feb 17 '17 at 10:42
  • You can make a timer in your program, and if time is out - execute 'shutdown.exe "/s /f /t 0'. – Ivan Kishchenko Feb 17 '17 at 10:53
  • I can but it means that I have to let the program running the whole time. – JiggyJinjo Feb 17 '17 at 10:55

1 Answers1

0

You could abort the shutdown with: shutdown.exe /a

If no shutdown was planned it returns:

Unable to abort the system shutdown because no shutdown was in progress.(1116)

Wollmich
  • 1,616
  • 1
  • 18
  • 46