Explorer Restart is a simple program that just restarts File Explorer (formerly known as Windows Explorer). The path of each open File Explorer window is noted, and each window is opened again after Explorer is restarted. The history of each window is not captured and cannot be restored, so you may wish to first use the Back or Up button in each window to navigate to the topmost folder within its respective folder tree.
How exactly does one go about restarting Explorer anyway? For over 35 years, Microsoft have failed to provide Windows with a real interprocess communication system. Various ghastly bodges exist, but there is no standard method to talk to a process as a whole. Apple introduced the phenomenal AppleEvent and Open Scripting Architecture technology a very long time ago now, while Windows lacks any kind of equivalent. Thus, it is not possible to instruct Explorer to quit. What do we do instead? A number of other people have implemented various pieces of this process already, but it does not appear that they have all been put together in a single program. The general process is as follows:
- Instantiate a Shell.Application COM object, enumerate its window list, and record the value of the
- Locate each window of class
CabinetWClass, and close it (from AutoHotkey forum topic Closing a simple explorer window after operations)
- Allow time for Explorer to catch up (750 ms at the time of writing)
- Now that (and only now that) Explorer has no windows open, post
WM_QUITto the window with class
Progman(from AutoHotkey forum topic Restart Explorer (the official way)); in Windows 10 at least, if there are open folder windows, they will prevent Explorer closing, but the forum topic makes no mention of this
- Wait for Explorer to close (for 7 seconds at the time of writing) then terminate it if it’s still running (and presumably not responding)
- Allow time for Explorer to finish closing (750 ms at the time of writing)
- Launch Explorer
- Allow time for Explorer to launch (1500 ms at the time of writing)
- Open each of the paths collected from open windows
Launch the program to restart Explorer. A progress window appears until Explorer has received the requests; the program may close before the re-opened windows finally appear.
All the delays placed between steps to allow Explorer to catch up are not scientific: they were simply added and adjusted until Explorer managed to close and restart without tripping over itself. Without these days, Explorer can get into a crash loop or otherwise malfunction and there is always a risk of this on slower or overloaded computers. This process has only been tested on 64-bit Windows 10 Pro 20H2 and Server 2016 desktop environment. If in any doubt, open a Command Prompt window first and be prepared to kill Explorer manually; once you are satisfied that this program is compatible with your PC, you can discard this safety net.
Initial version, 2021-07-11.
Explorer Restart is an open source application programmed in AutoHotkey. It requires the revised ahk2exe for build directives. The installer is built using Inno Setup. All graphics were created using Inkscape.
A copy of all the development files is available for download.
Explorer Restart is copyright 2021 Daniel Beardsmore. The Explorer Restart application (“program”) and source code are made available under the zlib license, the terms of which are included in a separate document. The program may be used without restriction free of charge.