" start-process -wait"在Windows 10上

时间:2017-05-10 07:06:33

标签: powershell

更新 排序"问题"我一发布这个问题。显然,Windows应用程序或其他任何名称,UWP" app"执行方式不同,导致问题。一旦我不使用" calc"或任何其他Windows应用程序,它按预期运行。

我想要按顺序启动和完成一个程序列表,并且在每个程序的退出时,列表(数组)上的下一个程序将启动。

该代码适用于Windows 7 SP1,即使使用PowerShell版本5(虽然我知道它并不完全相同)

但是,当我在Windows 10 Creative Update上运行它时(我手头没有其他版本)它出错了,-Wait参数似乎无效。

我对其他Powershell cmdlet也持开放态度,如果它有一个相当简单的" Wait"功能

# Common variable
$programlist = "calc", "notepad", "excel", "winword", "powerpnt"

-----
# Example 1
ForEach ($program in $programlist) {(Start-Process $program -Wait).WaitForExit;}

# Example 2
ForEach ($program in $programlist) {Start-Process $program -Wait -Passthru;}

# Example 3
Start-Process $programlist[0] -Wait
Start-Process $programlist[1] -Wait
...

# None of the examples work in Win 10, but works perfectly fine on Win7

1 个答案:

答案 0 :(得分:0)

我无法在Win10,PS 5.0版上重复您的问题。

您的代码运行良好。

您能提供更多详情吗?

很高兴听到它〜