开发者

Using Powershell to automating a bat file that ends with PAUSE

开发者 https://www.devze.com 2023-01-10 19:55 出处:网络
I have a batch file that I can\'t change, but I want to automate with Powershell 2.0.It ends with a PAUSE command, which displays:

I have a batch file that I can't change, but I want to automate with Powershell 2.0. It ends with a PAUSE command, which displays:

Press any key to continue...

Is there an way to ca开发者_JAVA百科ll this batch file from a powershell script, but have it exit without needing a user to press something?


You can pipe anything into the cmd process:

'' | cmd /c foo.cmd

which will be treated as input by cmd and that's enough for pause to stop pausing.

Sample code here.

0

精彩评论

暂无评论...
验证码 换一张
取 消