Auto Reboot Windows 7 Enterprise Every X Hours

I am running a bunch of vps servers which run Windows 7 Enterprise in order to run certain automated marketing software.

However, I am noticing after a few hours, the cpu gets a bit high so want to auto reboot the vps’s every 4 hours in order that the software runs on a clean slate (and to also avoid the “cpu abuse” warning from the hosts).

Its surprisingly simple to do this and requires only a couple of steps.

1. Open up the command prompt by typing CMD into the start window.

command-prompt

2. Copy the following code into the command window
set command=shutdown.exe /r /t 14400
echo %command% > "%APPDATA%\Microsoft\Windows\Start Menu\Programs\Startup\restart.bat"

command-prompt-2

NOTE: where it says 14400, this is the amount of seconds to wait before reboot. In this case its 4 hours but you can set this up for every 24 hours or every 60 seconds if you wanted.

3. Execute the command by pressing enter and this will create a file in the start folder of your machine so on next startup, it will be told to restart the machine in 4 hours time.

command-prompt-3

4. Now , reboot your machine and during the next start up the restart script will tell the machine to restart itself in 4 hours and every 4  hours afterwards.

command-prompt-4

JOB DONE!!

BONUS TIP
I also like to open the task manager on start up so in order to do that, run this in the command line.
set command=start "" C:\Windows\System32\taskmgr.exe
echo %command% > "%APPDATA%\Microsoft\Windows\Start Menu\Programs\Startup\start_task_manager.bat"