如何在不终止explorer.exe的情况下关闭所有已打开的资源管理器窗口
Close All Open File Explorer Windows Without Restarting explorer.exe
Got it, you want to shut down all open File Explorer windows without killing or restarting the core explorer.exe process—totally get why that’s preferable, since restarting would reset your taskbar and pinned items. Here are two reliable, non-disruptive methods to do this:
Method 1: Use PowerShell
This command targets only the individual File Explorer window instances, leaving the main explorer.exe (the one running your taskbar/desktop) untouched:
(Get-Process explorer).MainWindowTitle | Where-Object { $_ -ne "" } | ForEach-Object { $targetWindow = Get-Process explorer | Where-Object { $_.MainWindowTitle -eq $_ } $targetWindow.CloseMainWindow() }
Breakdown:
Get-Process explorerpulls all running explorer processes: the main taskbar process has an emptyMainWindowTitle, while open File Explorer windows have titles matching their folder paths.- We filter out the main process by keeping only entries with non-empty window titles.
CloseMainWindow()sends a gentle "close" signal to each window—just like clicking the X button, no forced termination involved.
Method 2: Use a Double-Clickable VBScript
If you prefer a one-click solution, save this code as CloseAllExplorerWindows.vbs:
Set objShell = CreateObject("Shell.Application") Set objWindows = objShell.Windows() For Each objWindow In objWindows ' Verify the window is a File Explorer instance If InStr(objWindow.FullName, "explorer.exe") > 0 Then objWindow.Quit() End If Next
How to use:
- Open Notepad, paste the code above.
- Save the file with a
.vbsextension (make sure "Save as type" is set to "All Files" to avoid saving it as a.txt). - Double-click the script, and all open File Explorer windows will close immediately.
Both methods will cleanly shut down your open folders without disrupting your taskbar, desktop icons, or the main explorer.exe process.
内容的提问来源于stack exchange,提问作者J. Hajjar
相关产品推荐
相关产品推荐

