Re: Running a DOS program using Microsoft Command Shell
- From: "Jouko Kynsijärvi" <jouko.kynsijarvi@xxxxxxxxxxxxx>
- Date: Sat, 8 Apr 2006 18:22:30 +0300
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.)
.
- References:
- Running a DOS program using Microsoft Command Shell
- From: netdawg
- Running a DOS program using Microsoft Command Shell
- Prev by Date: Re: [MSH] Tab Completion
- Next by Date: Splitting strings
- Previous by thread: Running a DOS program using Microsoft Command Shell
- Next by thread: Re: Running a DOS program using Microsoft Command Shell
- Index(es):
Relevant Pages
|