Closing All Explorer Windows in PowerShell

前端 未结 3 1209
北恋
北恋 2021-01-06 04:59

I am writing the following code to close all explorer windows with PowerShell:

(New-Object -comObject Shell.Application).Windows() |
 ? { $_.FullName -ne $nu         


        
3条回答
  •  粉色の甜心
    2021-01-06 05:21

    As per @ste's comment, the accepted answer may have stopped working after windows updates.

    I've solved it with something similar in Powershell.

    Watchout though as I've assumed any explorer processes with a window title are folders. This might not always be the case (eg maybe if copying files)

    get-process | ?{ $_.ProcessName -eq 'Explorer' } | ?{ "" -ne $_.MainWindowTitle } | Stop-Process
    

提交回复
热议问题