powershell - .Quit() 方法无法在 Windows 版本 1909 中关闭 PowerShell 中的文件资源管理器窗口
问题描述
我已经遵循了这些线程中的所有示例,但似乎在最新更新中发生了一些变化。
我的windows版本是: Version: 1909 BuildNumber: 18363
我坚持尝试使用带有以下代码的 PowerShell 关闭资源管理器窗口:
$myFolder = "C:\Program Files"
$shell = New-Object -ComObject Shell.Application
$window = $shell.Windows() | Where-Object { $_.LocationURL -eq "$(([uri]"$myFolder").AbsoluteUri)" }
write-output ($window.LocationURL -eq $(([uri]"$myFolder").AbsoluteUri))
# write-output $window.AbsoluteUri
# write-output ($window.HWND)
# write-output ($window.LocationURL)
# Get-Member -InputObject $window.Parent()
Get-Member -InputObject $window # prints out the methods associated with the window
$window.Refresh() # this method works
$window.Quit() # this method doesn't
$window.GoBack() # this method works
$window.Parent().Quit() # this doesn't
# $window | ForEach-Object { $_.Quit() }
如果您打开,C:\Program Files
您会看到代码中描述的方法有效,但Quit
方法无效。
解决方案
推荐阅读
- qt - 动态添加到 qml tabbar 和 stacklayout
- c# - 如何手动从机器人向 Microsoft Teams 发送“对话更新”?
- javascript - 来自用户界面的 Spring Boot AJAX POST 请求和 knockout.js 调试错误
- node.js - Node js html-pdf命令不适用于PHP
- javascript - 切换 Bootstrap 导航下拉菜单
- r - 从 Rscript 调用 mclapply
- c# - 光标位置 C# 不适用于图片框
- python - 为什么多处理的成本与正常方式相同
- php - 使用 foreach/for 循环访问多维数组中的值以在 HTML 表中显示
- decoding - 将脚本文本翻译成纯文本