Make a Program Restart Command

About: Studying Mechatronics Engineering in the Netherlands

I was making much modifications on Windows, so I had to restart "explorer.exe" fairly often. I used it that much that I created a restart command.

Teacher Notes

Teachers! Did you use this instructable in your classroom?
Add a Teacher Note to share how you incorporated it into your lesson.

Step 1: Make the Batch File

Open windows explorer, and navigate to an easy accessible path where you want to temporary save a file. Click the right mouse button, hover over "New", and click "Text Document".

Give it the name you want the command to be called (restart), followed by .bat (restart.bat), and make sure there is no .txt extension after the filename. If a dialog opens about changing the file extension, you did it the right way and click "Yes".

Right click the file and click "Edit".

Step 2: Typing Some Code...

So, you probably have notepad open with in the title bar "yourFileName.bat - Notepad".

Okay, let's add some code!

1) First, we have to check that there is an argument passed, the program name. This can be done using:

@if %1.==. (goto error) ELSE (goto restart)

2) Next, add the function "restart":


The command to kill the program:

@taskkill /f /im %1 >nul

Wait a couple of seconds (3):

@timeout /t 3 /nobreak >nul

Start the program again:

@start %1 >nul

Say something, and go to the end of the file:

@echo restart complete
@goto exit

3) Add the function "error":


Say something, and go to the end of the file:

@echo Oops... something went wrong!

4) Add the function "exit":


Creating code finished... Hit save (Ctrl + S), and close notepad.

Step 3: Moving the File

Back at windows explorer, select your just finished file, and hit "Cut" (Ctrl + X). Navigate to C:\Windows\System32, and paste the file (Ctrl + V).

Step 4: Test Your Command

Open Command prompt (# + R, cmd.exe) and type "insertYourCommandNameHere explorer.exe". (restart explorer.exe). Your taskbar should disappear and reappear again. !!! All your open explorer windows will be closed too !!!.

Step 5: The Full Code:

@if %1.==. (goto error) ELSE (goto restart)

@taskkill /f /im %1 >nul @timeout /t 3 /nobreak >nul @start %1 >nul @echo restart complete @goto exit

@echo Please specify a program... @goto exit


Tech Contest

Participated in the
Tech Contest



  • Indoor Lighting Contest

    Indoor Lighting Contest
  • Make It Fly Challenge

    Make It Fly Challenge
  • Growing Beyond Earth Maker Contest

    Growing Beyond Earth Maker Contest

3 Discussions


1 year ago

I need this, but to close and re start a program like, lets say as example, phothosop. I manage to close it, but it is not able to find the program to restart.... in wich line I specify the route of the program to open?

tnank you


3 years ago

since the latest win 10 update my taskbar was stuck visible and had to restart explorer, now I have a one click op.



3 years ago

This is extremely useful!

A good idea to expand upon this would be to add a "Try again?" Y/N prompt upon encountering an error.