I'm working on a program which does a similar thing to the make.exe utility. I can spawn a cmd.exe process from within this utility and redirect it's output, but i can't seem to redirect the input.

essentially my program parses a .myk file and issues the appropriate command lines to cmd.exe(or command.com). At the moment I can send the command line at the time I spawn the cmd.exe process but once it's running I can't get any input to it. It'd be more efficient to spawn 1 cmd.exe and then send the commands to the one process.
So dose anyone have an example of issuing commands to a redirected console input.
Posted on 2003-03-06 04:53:48 by MArtial_Code
Have you tried cmd.exe mytemp.bat?

Regards, P1
Posted on 2003-03-06 10:45:43 by Pone
If I can't pass each command directly then a batch file would be the second best solution.
Posted on 2003-03-06 11:11:32 by MArtial_Code

I'm working on a program which does a similar thing to the make.exe utility. I can spawn a cmd.exe process from within this utility and redirect it's output, but i can't seem to redirect the input.

essentially my program parses a .myk file and issues the appropriate command lines to cmd.exe(or command.com). At the moment I can send the command line at the time I spawn the cmd.exe process but once it's running I can't get any input to it. It'd be more efficient to spawn 1 cmd.exe and then send the commands to the one process.
So dose anyone have an example of issuing commands to a redirected console input.


Dunno if this helps, but for example


echo y | del *.*

Answeres y(es) to the "are you sure?" question.

blah < bleh.txt

Gets blah to read the contents of bleh (the shell passes bleh.txt to blah)
Posted on 2003-03-06 11:15:58 by bazik
i think if i am not wrong that i saw a source(tasm16), called redir that redirects input, but the annoying thing is that you don?t see the input from the keyboard in the dos-windows.. :-/
but you can redirect with=
cmd>log.txt
cmd|copy con:log.txt
or something like that.. :alright:
Regards
Posted on 2003-03-06 13:37:42 by Rygar
Can't you just set the stdin/stdout handles in a STARTUPINFO struct and use CreateProcess for each process?

Thomas
Posted on 2003-03-06 13:40:06 by Thomas
Ok finally after porting several C sources I've found one which works for me the c source is at Console IO redirection C source

I've split the code into it's functional subroutines which can be used for most situations i think.
this source shows redirecting the stdin and stdout handles of a hidden child cmd.exe process.
the program then issues four commands (dir,ver,vol,exit) to cmd.exe and displays the results.

the asm file must be built as a console app.
Posted on 2003-03-09 19:03:53 by MArtial_Code