Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I want a system restart batch script to:

  1. On first execution, it should put this script in startup folder
  2. It should re-start the system. So that it keeps on restarting user's system.

Can you please guide me in this? Thanks in advance

share|improve this question
    
Why would anyone want to do this? –  pratnala Feb 14 '13 at 9:42
    
It may not be practical, but it would be a practical joke. –  ioSamurai Feb 14 '13 at 9:53
    
you want help to screw up others ?? –  user568109 Feb 14 '13 at 10:00
    
@all sorry if it was a idiotic question, but I was writing a article on anti-virus programs and I was testing whether these type of batch files will be detected by any antivirus –  Neha Sharma Feb 14 '13 at 10:10

1 Answer 1

up vote 2 down vote accepted

The command to restart your PC is

shutdown.exe /r /t 00
  • /r is the switch for restarting
    /s stands for shutdown
    /h is for hibernating
  • /t XX is the time in seconds to wait until the command is executed

Your startup folder can be accessed via an environment variable

%APPDATA%\Microsoft\Windows\Start Menu\Programs\Startup

Your batch file to create another batch in that folder with a specific command could look like

set command=shutdown.exe /r /t 00
echo %command% > "%APPDATA%\Microsoft\Windows\Start Menu\Programs\Startup\restart.bat"

Source

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.