Closing All Explorer Windows in PowerShell

前端 未结 3 1221
北恋
北恋 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:05

    I think there's something in the pipeline that goes wrong. This code works:

    $a = (New-Object -comObject Shell.Application).Windows() |
     ? { $_.FullName -ne $null} |
     ? { $_.FullName.toLower().Endswith('\explorer.exe') } 
    
     $a | % {  $_.Quit() }
    

提交回复
热议问题