Create Simple Script to Close and Restart Explorer Automatically in Windows

Many times we need to log off or restart Windows to apply the changes made by a registry script or software. Sometimes we can avoid the log off or restart by doing a simple “End Task” of Windows Explorer and restart Explorer using Task Manager as mentioned in following tutorials:

End_Task_Windows_Explorer_Task_Manager.png

But doing End Task and restarting Explorer using Task Manager requires a few manual steps. Wouldn’t it be great if you can get a simple shortcut on Desktop or Quick launch toolbar and simply click on it to automatically end task and restart Explorer?

Advertisement

Today in this tutorial, we are going to share a simple Batch script which can end task of Explorer and then restart it automatically.

Simply copy paste following code in NOTEPAD and save the file with name “Restart_Explorer.bat” (including quotes):

@ECHO OFF
echo.
echo.
echo Simple Script to Restart Windows Explorer
echo.
echo Created by “Vishal Gupta” for AskVG.com
echo.
echo.
echo STEP 1: Closing Explorer . . .
echo.
TASKKILL /F /IM explorer.exe
echo.
echo.
echo STEP 2: Starting Explorer . . .
start explorer.exe
echo.
echo SUCCESS: Explorer is running.
echo.
echo.
PAUSE

That’s it. You can place this script at any location like Desktop, Quick Launch toolbar and whenever you need to restart Explorer, simply run the script.

PS: If you don’t want to create the script manually or face any problem while creating the script, you can download a ready-made script using following link:

Download Link

Also check:

Advertisement

Published in: Windows 7, Windows 8, Windows Vista, Windows XP

About the author: Vishal Gupta (also known as VG) has been awarded with Microsoft MVP (Most Valuable Professional) award. He holds Masters degree in Computer Applications (MCA). He has written several tech articles for popular newspapers and magazines and has also appeared in tech shows on various TV channels.

Comments

NOTE: Older comments have been removed to reduce database overhead.

  1. Hey, thanks for posting this up. Great little script that’s been really useful for me. It’s saved me having to do a lengthy restart on several occasions now.

    I sometimes get a problem in Windows 7 where windows explorer just suddenly stops auto refreshing any file changes I make (copy paste etc) and the only solution was always a full restart of my system.

    Now I just run this little script instead and 2 seconds later all is working again.

    Thanks a lot 🙂

  2. You can actually name the file whatever you want so long as you put “.bat” at the end of it (not including quotes). You can also replace “PAUSE” with “exit” at the very end of the script to have it automatically close the command prompt. :p

  3. hi
    thanks for your trick. after restart explorer the new black window will be opened. how to close this windows then?

  4. hi i replaced “PAUSE” with “exit”. my problem is resolved.
    thanks for dxsyndicate

  5. can the script change to Script to Close and Restart outlook Automatically in Windows..please help

  6. I have a VB6 application, which when it starts, closes the windows explorer and relaunches it before it exits.

    The code that worked perfectly till Windows 8 is this..

    Const WM_QUIT As Long = &H12
    Const WM_QUIT_WIN As Long = &H5B4
    //For Windows 7
    lngHandle = FindWindow(“Shell_TrayWnd”, vbNullString)
    If lngHandle 0 Then
    PostMessage lngHandle, WM_QUIT_WIN , 0, 0
    End If

    //For XP
    lngHandle = FindWindow(“Progman”, vbNullString)
    If lngHandle 0 Then
    PostMessage lngHandle, WM_QUIT, 0, 0
    End If
    The same code however fails to close explorer in Windows 10. It does sometimes close the explorer but then it restarts. Closing the explorer is not consistent in its behavior.

    Is there any thing that has changed in Windows 10 which prevents the messages to close the explorer.

    Any help would be appreciated. Thanks in advance.

  7. Dont work in 64bit windows!

    but it works:

    taskkill /f /im explorer.exe
    start “” “%windir%\explorer.exe”

  8. I want to open and close a webpage for about 10 millisecond is that possible I think not 90 % fail
    IF you can that task I mean you that you are expert in batch file thats it

  9. Lol – Before commenting why not try it. Start Explorer.exe does NOT work on 64 bit Windows; after killing Explorer, if you issue the simple Start Explorer.exe you get a File Manager window and not the desktop.

Leave a Comment

Your email address will not be published. Required fields are marked *

NOTE: Your comment may not appear immediately. It'll become visible once we approve it.