Re: Running a DOS program using Microsoft Command Shell

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



netdawg wrote:
Automate a DOS program which needs response to prompts. The
responses, in order, are:

[ENTER/CARRIAGE RETURN]
NO
YES
INPUT.TXT
NO
OUTPUT.TXT
[ESCAPE KEY]

What I have learnt so far:

I can use "invoke-item" to fire up the executable just fine, but
wondering how to pass the above args to that window. The program
needs to be "fooled into" thinking that it is being run in a DOS
prompt (CMD.EXE) with those commands being punched in from the
keyboard.

Depending on how the DOS program reads it's input, in cmd.exe you could just
use "test.exe < input.txt" where input.txt would contain the responses.

MSH doesn't yet support the < redirection operator, but we can use MSH to
create the input.txt with escape character and run the executable under
cmd.exe:

$input = combine-path $env:temp test-input.txt
@"

NO
YES
INPUT.TXT
NO
OUTPUT.TXT

"@ + [char]27 > $input
cmd /c "test.exe < $input"
remove-item $input

(Note that the empty lines inside the string are required to get the desired
input.)


.



Relevant Pages

  • Problems opening a DOS program from Win ME
    ... I execute the DOS program using a simple DOS command shortcut from the ... flashing cursor in the top left, and if I hold th escape key down, I ... Initial Environment: Auto ... Extended Memory Auto ...
    (comp.os.msdos.misc)
  • Re: Problems opening a DOS program from Win ME
    ... > My front office desk is running Win ME, and runs ME because I need to ... > run a DOS program to do billing. ... > flashing cursor in the top left, and if I hold th escape key down, I ...
    (comp.os.msdos.misc)