YZlat
asked on
Scheduled reboot
I am creating a windows service that should run every hour, check database for a reboot date and time and schedule reboot based on the datetime it finds in the database.
I can use Windows scheduler to schedule my windows service and I took care of the data retrieval part. Now I am trying to find the best way to schedule a reboot based on the retrieved value.
Should I use the registry HKEY_LOCAL_MACHINE\Softwar e\Microsof t\Windows\ CurrentVer sion\Polic ies\Explor er? if so, could you give me an example?
or should i use System.Diagnostics.Process .Start("Sh utDown", "/r")?
Also before a reboot I want to show the user a messagebox warning.
Can anyone help?
I can use Windows scheduler to schedule my windows service and I took care of the data retrieval part. Now I am trying to find the best way to schedule a reboot based on the retrieved value.
Should I use the registry HKEY_LOCAL_MACHINE\Softwar
or should i use System.Diagnostics.Process
Also before a reboot I want to show the user a messagebox warning.
Can anyone help?
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
paulmacd, can you give me some examples?
-tjs, I need examples using .NET
-tjs, I need examples using .NET
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
But how can I schedule it at a particular date and time?
For instance if the date retrieved from the database is April 1st 11:00am, how can I schedule the reboot at that time?
For instance if the date retrieved from the database is April 1st 11:00am, how can I schedule the reboot at that time?
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
paulmacd, I have searched everywhere but cannot find AT command or switch anywhere
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
paulmacd, I am working on using
System.Diagnostics.Process .Start("Sh utDown", "/r /t 300 ")
as you suggested. I get a message displayed that tells me how much time left till shutdown. How can I add a snooze button to it?
System.Diagnostics.Process
as you suggested. I get a message displayed that tells me how much time left till shutdown. How can I add a snooze button to it?
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thank you. I am gonna give that a try
ASKER
thanks for your help, you pointed me in the right direction
Very happy to help.
schtasks /create /tn "Reboot Once" /tr "shutdown /r /f /t 1 /d p:0:0" /sc once /st 23:00 /s MyServer1
This creates a scheduled task on MyServer1 that runs only one time at 11:00pm (/st) and executes the local shutdown command with a 1 second warning and enters a bogus restart reason (/d p:0:0) so the admin isn't prompted to enter a reason when the reboot is done.