Scheduling Automatic Restart of Windows 7

One of the lessons I have learnt with server administration is that after a while of running tomcat servers, the system can get really sluggish from all the "living objects". One of the solutions for this is to do a daily scheduled reboot of the server to keep the system fresh and performing at its best (of course you also need to fix the reason as to why objects are not being pushed into garbage collection).

So, here is how you create a scheduled restart for Windows machines (This was tested for Windows 7):
  1. Start Notepad,
  2. type c:\windows\system32\shutdown.exe -F -R
  3. Save the file as "AutoRestart.bat" somewhere on disk
  4. Now, Launch Task Scheduler.
  5. Click Action and select Create Basic task.
  6. Type AutoRestart (or others you want) in the Name box and click Next.
  7. Select Daily and click Next
  8. Type the time you want to restart the computer and click Next.
  9. Select Start a program and click Next.
  10. Click Browse and navigate to where you saved AutoRestart.bat, select the AutoRestart.bat file and click Next.
  11. Click Finish.
  12. To test if your auto-restart works, go back to task scheduler and when you see the list of scheduled tasks, right click on AutoRestart and select run.