在PowerShell中关闭所有Explorer Windows [英] Closing All Explorer Windows in PowerShell
本文介绍了在PowerShell中关闭所有Explorer Windows的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在编写以下代码以使用PowerShell关闭所有资源管理器窗口:
I am writing the following code to close all explorer windows with PowerShell:
(New-Object -comObject Shell.Application).Windows() |
? { $_.FullName -ne $null} |
? { $_.FullName.toLower().Endswith('\explorer.exe') } | % { $_.Quit() }
但是它不会关闭所有打开的窗口.
相反,它仅关闭RoundDown(N/2)+1
窗口,并使RoundUp(N/2)-1
窗口保持打开状态.
But it does not close out all the open windows.
Instead, it closes only RoundDown(N/2)+1
windows, and leaves RoundUp(N/2)-1
windows open.
任何人都可以帮忙吗?
推荐答案
我认为管道中出现了某些问题. 这段代码有效:
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() }
这篇关于在PowerShell中关闭所有Explorer Windows的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文