|Wer ist online?|
|Wir haben 51 Gäste online|
|Scheduled Windows restart|
|Source Code - Kommandozeilen-Skripte|
|Geschrieben von: Thomas|
|Donnerstag, 20. August 2009 um 17:15 Uhr|
Seite 1 von 2
In general, Windows is a relatively stable operating system. Applications on the other hand are not always so reliable, and even some Microsoft applications are pretty good examples for poorly developed software. Sometimes a long running computer should be restarted to clear up resources consumed by leaky and crashy software.
The MS knowledge base article http://support.microsoft.com/kb/293814 explains where we have to start tweaking.
REG ADD HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Reliability\UserDefined /v "P;241;50000" /t REG_MULTI_SZ /d "Scheduled System Cleanup Restart\0This is the message." /f
Once the custom reasons have been entered into the registry, we modify the shutdown command accordingly:
SHUTDOWN -r -t 180 -d up:241:50000 -c "This is my comment."
Windows still doesn't know when to initiate our shutdown. We're going to use the Task Scheduler for this. It is important that this service is up and running, which is the case on most systems anyway:
NET START schedule
The command line utility At lets us schedule tasks.
This line performs the restart on every Sunday at 9:00 in the morning:
AT 09:00 /every:SUNDAY SHUTDOWN -r -t 180 -d up:241:50000 -c "This is my comment."
Putting all these commands together in one command line script gives us a pretty good installer for the scheduled shutdown:
For the deinstallation we will later need the task ID the AT command has created for our scheduled entry. We get this ID directly when AT has finished processing the task creation. Storing this ID somewhere for later use when the scheduled shutdown should be removed again would be one way of remembering it, but I do want to keep it simpler than that.
Instead of storing the ID somewhere for the task removal, the AT command can output a list of scheduled tasks. All we have to do is find our entry and remove it again. This means that we remember our SHUTDOWN parameters instead of the AT ID.
Copying the line with the SET gives us access to our shutdown command to find it in the task scheduler again.
|Zuletzt aktualisiert am Samstag, 22. August 2009 um 17:42 Uhr|
Du musst dich anmelden oder registrieren, um einen Kommentar zu schreiben.
Im Forum diskutieren. (0 posts)