1

Sometimes I have to restart explorer.exe, but I often have many folders open, that get closed in the process. How can I still have these folders open after restarting explorer.exe? I was also thinking about writing a script to get a list of currently open folders, but couldn't find out how to do that either.

Johannes Riecken
  • 229
  • 1
  • 3
  • 9
  • yes, because of an error, sometimes parts of the display don't update or the start menu becomes unresponsive. Then I'd kill explorer.exe via the task manager and run it anew, which solves those errors, but also closes all open folders. – Johannes Riecken Apr 29 '13 at 13:50
  • Does this answer your question? [How to restart explorer without losing open windows?](https://superuser.com/questions/1700083/how-to-restart-explorer-without-losing-open-windows) – Destroy666 Jul 27 '23 at 11:44

1 Answers1

1

Use this powershell code for this:

$open_folders = @()
$shell = New-Object -ComObject Shell.Application
$shell.Windows() | Foreach {
  $open_folders += $_.LocationURL
}
taskkill /f /fi "status eq not responding" >$null
Stop-Process -Name explorer -Force
explorer.exe
$open_folders | foreach {
  Invoke-Item $_
}

This uses Shell.application to list and restore open folders and kills not responding processes.

Wasif
  • 7,984
  • 2
  • 19
  • 32
  • Didn't work for me in 2022 (Win10)... Try [this](https://superuser.com/questions/1700083/how-to-restart-explorer-without-losing-open-windows/1700084#1700084) `batch` method. – goldnick7 Jan 19 '22 at 01:46