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() }
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.
Can anyone help with this?