views:

53

answers:

1

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 call this batch file from a powershell script, but have it exit without needing a user to press something?

+3  A: 

You can pipe anything into the cmd process:

0 | cmd /c foo.cmd

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

Sample code here.

Joey