17

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?

1 Answer 1

21

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.