Is there a way to restart all instances of Windows Explorer? It's useful when explorer starts acting up, eg. high cpu .
Asked
Active
Viewed 1,321 times
3 Answers
2
; Ctrl F9 - restarts all windows explorer.
^F9::
Runwait TASKKILL /F /IM explorer.exe
Run explorer.exe
return
Runwait will wait for the command to complete before going to the next line. This is required, else Run explorer.exe might run too soon, and get killed as well.
tinker
- 350
1
I have designed a better one using powershell:
$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 $_
}
It will open the folders which were open before restarting of explorer and kill not responding processes before explorer restart.
wasif
- 9,176
1
; Get a list of all opened explorer windows:
If WinExist("ahk_class CabinetWClass") ; explorer
{
list := ""
; https://autohotkey.com/boards/viewtopic.php?p=28751#p28751
for window in ComObjCreate("Shell.Application").Windows
{
explorer_path := ""
try explorer_path := window.Document.Folder.Self.Path
list .= explorer_path ? explorer_path "`n" : ""
}
list := trim(list, "`n")
}
; MsgBox, %list%
RunWait, %comspec% /c taskkill /f /im explorer.exe ,,hide
Process, WaitClose, explorer.exe
; We can now restart the Explorer.exe Process:
Run, explorer.exe
; open all explorer windows we had open previously:
If (list != "")
{
Process, wait, explorer.exe
Loop, parse, list, `n
Run %A_LoopField%
}
Relax
- 3,785