管道输入powershell命令

时间:2014-10-16 07:13:40

标签: powershell

我尝试在PowerShell的循环中运行exe,但程序以Press any key to continue结束,所以我的循环挂起。

到目前为止我的代码是:

foreach ($num in 1..50) { .\somethig.exe }

在bash中,我可以使用yes命令,但在PowerShell

中找不到类似内容

1 个答案:

答案 0 :(得分:1)

假设您必须输入' y'通过暂停,

PS> 1..3 | % { write-output y | cmd /c pause }
Press any key to continue . . .
Press any key to continue . . .
Press any key to continue . . .
PS> 

PS> 1..50 | % { write-output y | .\something.exe }

'%'是Foreach-Object的别名

相关问题