My friends at MDL forums asked me to code two simple tools, one of them, to exit the Explorer shell in Windows 10 and the second one to restart the Explorer shell. Both tools are designed to be used in batch files and scripts, as requested. I would like to share them with you and explain why they are different from the usual ways people use to restart Explorer.
These tools are compatible with any Windows version and edition with .NET Framework 4.5 installed, so they work natively in Windows 8 and above.
The first tool is ExitExplorer. It performs a graceful exit of the Explorer shell, so that settings such as your desktop icon layout, Quick Launch settings, UI preferences and all Explorer-related settings will be saved when you exit it. You can test the difference by yourself:
- Note your current Desktop layout, e.g. how your icons are arranged right now.
- Re-arrange them in any way you want.
- Traditionally, the taskkill command is used in batch files to "exit" the explorer shell, so open an elevated command prompt and run the following command:
taskkill /IM explorer.exe /F
The Explorer shell will be terminated.
- Now open the Task Manager and click File -> New Task menu item. Type explorer.exe in the Run box and press Enter.
Explorer will start again, you will see your Desktop, however, your icon layout will not be preserved. Your previous customizations will be lost, because taskkill terminates the Explorer shell but not exit it properly.
- Now rearrange your desktop icons again and try to use ExitExplorer.exe instead of the taskkill command. Your icon layout will be preserved, as it uses the "official" way to exit the Explorer shell!
That is all that's required from this simple app.
While the ExitExplorer app closes the Explorer shell properly, it does not start Explorer again. It's not of much use for scenarios where you need to restart Explorer. This was the second request, so I quickly made the RestartExplorer app. It does the same exit Explorer action but starts a new instance of Explorer, so you don't need to use Task Manager to run it manually.
Besides using these tools in batch files, you can pin these apps to the Taskbar or to the Start menu and launch them when you need them.
Bonus Tip: Using the RestartExplorer app, you can start the Explorer shell as administrator. Here's how:
- Right click the RestartExplorer.exe file and choose Run as administrator from the context menu.
- Press Win + R shortcut keys together on the keyboard to open the Run dialog.
The dialog will say that any tasks started will open elevated:
Use caution when running Explorer in the elevated mode constantly, it is a security hole. Use it only when you know what you are doing.
Winaero greatly relies on your support. You can help the site keep bringing you interesting and useful content and software by using these options:
If you like this article, please share it using the buttons below. It won't take a lot from you, but it will help us grow. Thanks for your support!