On the command line on Windows 8.1, how can I kill/close all Windows file explorer windows... but without killing and restarting the shell?

It's crazy that they're the same process.


2 Answers 2


You can use the command line utility NirCmd (freeware) (archive.org's mirror for the webpage; archive.org's mirror for the binary) and execute:

nircmd.exe win close class "CabinetWClass"

I use it on Windows 7 SP1 x64 Ultimate and it works as intended: it will close all Windows Explorer windows, but won't kill the explorer.exe process.

The program is supposed to work on Windows 9x/ME, Windows NT, Windows 2000, Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7, Windows 8, and Windows 10.

  • 1
    Thanks! Sorry it took so long to mark "answered". I'd totally forgotten I'd posted this question over a year ago, and just searched for a solution on Google again now only to find my own question here! nircmd rocks.
    – LaVache
    May 28, 2019 at 2:15

Complementing Franck's brilliant response:

You can automate a shortcut to this command by following the steps:

  • create a new folder somewhere you like
  • inside it, paste the app "nircmd.exe"
  • still inside it, create an expkill.txt file with the command informed by Franck:
    nircmd.exe win close class "CabinetWClass"
  • change the .txt file extension to .bat file, turning into expkill.bat
  • create a shortcut to this file and change its name to just "expkill"
  • move this shortcut to the 'user folder'


now whenever you type the steps below, windows explorer windows will be closed WITHOUT terminating the explorer.exe process

  • [CTRL + R]
  • expkill
  • [ENTER]


Don't know how to access the user's folder?
Follow the instructions:

  • type [Win + R]
  • type just a dot:.
  • type [enter]
  • the folder you open is the user's folder

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.