【问题标题】:Run an application with PowerShell and wait until it is finished使用 PowerShell 运行应用程序并等待它完成
【发布时间】:2011-12-16 00:26:48
【问题描述】:

是否可以使用PowerShell 运行应用程序并等待它完成? 例如我想运行Thunderbird 并在用户关闭它之后,然后在输出中打印一些东西?

第二件事 - 是否可以像在开始菜单中一样使用 thunderbird 关键字搜索此应用程序(当我们手动键入时,它会返回结果 Mozilla Thunderbird) - 并运行它?

谢谢!

【问题讨论】:

  • 非常相似的东西here

标签: windows-7 powershell


【解决方案1】:

你可以这样做:

Start-Process myprogram.exe -NoNewWindow -Wait

或者,如果您想要更简洁的机制,总有Out-Null hack:

myprogram.exe | Out-Null

管道将等待程序终止,因此我们管道到Out-Null

至于查找应用程序,SO question 介绍了如何执行此操作。这是另一篇展示this method的文章。

您可能还想看看这篇文章,了解如何制作Powershell interact with Windows Searchthis one,这是开始按钮使用的。

【讨论】:

  • 工作正常 - 你有任何寻找应用程序的解决方案吗?
  • @hsz,用指向某人提出的类似问题和解决方案的指针更新了我的答案。我不知道有什么快速破解方法,但如果我找到了,我会添加它。
  • Invoke-Expression "$($complete_command_with_args) | Out-Null" 为我工作。
猜你喜欢
  • 1970-01-01
  • 2019-10-20
  • 1970-01-01
  • 1970-01-01
  • 2017-10-17
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多