简体   繁体   中英

Pipe enter to powershell command

I try to run exe in a loop in PowerShell, but the program ends with Press any key to continue , so my loop hangs.

My code up to now is:

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

In bash I could use yes command but I cannot find anything similar in PowerShell

Assuming you have to type in 'y' to get pass the pause,

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 }

'%' is an alias for Foreach-Object

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM