I would like to write a batch/cmd script to pass arguments to another command-line program.

However, I'd like to display the output of that program in the batch file, and be able to interact with the program normally.

Effectively, the batch file becomes a transparent way to access the program.

How do I do this?

  • 1
    Use the expect utility.
    – stark
    Nov 16, 2016 at 19:47
  • @stark I'd rather do it without any third-party software, if possible. Nov 16, 2016 at 19:49
  • 2
    You might also check the internal call command.
    – user373230
    Nov 16, 2016 at 19:51
  • 1
    @Chinggis6 Thanks, it would be great if you can expand on this in an answer and I'll accept it. Nov 16, 2016 at 19:52

1 Answer 1


I couldn't understand the question very clearly but call is the command that comes to my mind. It is an internal command being a feature of cmd.exe as external commands exist as separate executable files, usually in %SystemRoot%\System32 folder.

call command executes other batch files (with .bat extension) within the calling script and may pass arguments to that external executable file assigned as to its parameters.

Moreover, call command may call for label (defined as :MyLabel inside the batch file, and otherwisely intended and working with GOTO command as points or sections in a batch file to switch the execution to, which is an old and might also be a wrong feature) within the script itself without referring to any external batch file.

The command is well documented in an SS64 page, and it's main difference from just calling the other script or executable file without any using any command, say as MyScript.bat or MyExecutable.exe is that it doesn't leave and exit the current script when calling or upon the external script's finishing, keeping it in the current session, and comes back to and continues executing the calling script's following lines, where the call is originated from.

  • I'm not using the feature for long, but that's what I remember from my experience of using it :)
    – user373230
    Nov 16, 2016 at 20:03
  • I'm on Fedora, I cannot test it on Windows, but good examples are provided in the page as well as here.
    – user373230
    Nov 16, 2016 at 20:07
  • Could you add an example usage? Jan 21, 2017 at 14:12

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .