Reboot Computer Automatically in Batched or Scripted Mode
March 23, 2007
When I was talking about the trick to update the in-use file with new version the last step to say good-bye to the current session and start working with the updated version was to reboot the PC. Quite reasonable one would ask if it’s possible to automate this process too? Yes, we can reboot the PC automatically using shutdown utility that come with Windows distribution and is locate in the %systemroot%\system32\ folder. To automate the reboot procedure we need to pass -r switch to input of the shutdown.exe tool
shutdown -r [-f]
By the way, notice the [-f] parameter I put in the command line in addition to the -r parameter. It is an additional parameter used to force computer shutdown and force closing of running tasks. Use this switch carefully as you will lose data that hasn’t been saved before running the reboot.