Search code examples
batch-filecmdexternalexe

Running External Commands on an .exe from a Batch Code


I am trying to run an .exe program entirely from batch commands. This program is in cmd prompt format (the .exe opens a command prompt and the user types in various commands to run). After using this command:

START /b [path] [.exe file]

The desired program is running in the command window. My problem arises next when the program prompts the user for commands (ex: "Enter Name - "). To these prompts I wish to respond with commands that will be recognized by the program (ex: to the prompt "Enter Name - ", I wish to respond "NAME" and click enter/return to display the next prompt).

I have tried using the echo command but after successfully printing what I want into the command line, I need the program to hit enter/return to move on to the next prompt. Any suggestions?

Thanks


Solution

  • The START command still admits stdin redirects. Therefore it should be possible for you to run,

    START /b path\to\exe\file <path\to\canned\responses\file
    

    For your specific case you could try,

    @echo off
    >tempinputfile echo reply foo
    >>tempinputfile echo reply bar
    start /b path\to\exe\file <tempinputfile