Link to home
Start Free TrialLog in
Avatar of johnlwarence
johnlwarence

asked on

simulating a key press in a ms-dos batch file

i need to simulate a key press in an ms-dos batch file

it reads:

press any key to continue

and i need to batch file to do that for me
ASKER CERTIFIED SOLUTION
Avatar of Lee W, MVP
Lee W, MVP
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial

Why not just edit the batch file and comment out the 'pause' command?

::pause

or

rem pause
That assumes there's a pause in the batch file.  

True, but I think it's not a stretch to assume that if a batch file produces the output "press any key to continue", and requires a keystroke to continue, that a 'pause' command is behind it...

But you are correct, there could be a different, third-party program called by the batch file to produce that scenario.
Avatar of Watzman
Watzman


Try input redirection.

Create a text file with the keyboard responses in it, in this case a "Y" on a line by itself.  Call it "yes.txt"

Then

C:\>runthis.bat<yes.txt

The batch file gets it's input from the text file instead of the keyboard.  This doesn't always work, and even when it does may take some experimentation and playing around with to get right.  Also, if there are other responses, they will have to be there also.



Um, excuse me... Did you read my first comment?

That's what I said to do.
Hey, lee ... I didn't read your post that closely, but you are right.  I agree that you should get the points.  Unfortunately, I'm not the author.