【问题标题】:Close "This PC" using command line or Powershell on Windows 10在 Windows 10 上使用命令行或 Powershell 关闭“此 PC”
【发布时间】:2019-04-10 15:10:05
【问题描述】:

如果我在 powershell 中输入“explorer”,它会打开“This PC”。如何使用命令行或 powershell 脚本关闭“这台电脑”?

【问题讨论】:

  • 当我做 Get-Process | Where-Object {$_.MainWindowTitle -ne ""} | Select-Object MainWindowTitle, ID,有时会显示“This PC”,但不是一直显示。

标签: windows powershell command-line shutdown


【解决方案1】:

你想通过没有起始位置的 PowerShell 启动“explorer.exe”来完成什么?

您正在运行什么操作系统?在 Win10 上,这将在“快速访问”处打开。

您可以使用 PowerShell 将资源管理器打开到您选择的任何目录

Invoke-Item -path SomeQuaifiedPath

# or 

ii SomeQualifiedPath

您可以获取给定进程的主窗口名称,当然还有它的 ID,并使用 Stop-Process cmdlet 通过任一属性停止它们。

Get-Process | 
Where-Object -FilterScript {
    $PSItem.MainWindowHandle -ne 0 
} |
Select-Object -Property Name, Description, MainWindowTitle, Company, ID |
Out-GridView -Title 'Choose Application to Kill' -PassThru | 
Stop-Process -Force -Confirm:$true

【讨论】:

    【解决方案2】:

    这对我有用

    Start-Process Explorer
    $explorerID = (Get-Process Explorer).Id
    Stop-Process -Id $explorerID
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-01-04
      • 1970-01-01
      • 1970-01-01
      • 2020-01-01
      • 2018-12-11
      • 2012-10-29
      相关资源
      最近更新 更多