Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
Is there a way for batch files to interact with executables? If you run an external program with a batch file, and then it asks for input or for the user to make a selection, can batch files interact this way?
The UNIX analogy that I am more familiar with would be:
program<<eof
input1
input2
input3
eof

Depends on the program and how it accepts input. If you are trying to pass parameters to the program like /a or -O then yes you can.... This would be your batch line:
Program input1 input2 input3
type it in the batch file exactly how you would type it out on the command line. Execution will then return to the batch file once your program has finished running. So you could add the line:
ECHO Ok All Done.
After the one above, and it would execute as soon as your program was finished.

But that would only work if Program uses variables passed to it at execution. I'm looking to pass information to Program after it has been executed. IE: if at a later point in time, Program were to give the user a prompt requesting a certain type of information, and the user had to manually put that information in.

Nope U cannot. You can only execute commands using DOS. It can't interact with a program. Once DOS calls up the second program, it passes the execution to it and halts.
eg..
DOS
command
command
call Program/batch X <= point Q
command <= point R
After point Q, if the external program finished running and exited, DOS can continue to point R.However, if, at point Q, the external program asks for some input and pauses .. well .. as far as I know, manual intervention is called for.

That's what I was concluding upon. I do it all the time with unix shells, so I figured I was just missing something obvious with batch files, but apparently not. Thanks for the help.

There is an exception if you are using a program such as osql or ftp which have command line options that will accept commands from a text file.
But it works a little different than what you described, it would be:
ftp -s:script.txtand script.txt would contain the commands you wanted to execute while running FTP.

Hello,
Actually, I was trying to do the same thing. If you have a batch program that asks for user input (ie. y or n), you can do this by putting the y or n into a text file, along with a carriage return. You can then pass the <filename.txt to the command.
Example...
gpupdate /force <N.txt
Where N.txt is a text file in the same directory containing an N and carriage return.
Hope this helps.
David.

![]() |
from JDK1.4 to JDK1.5
|
I need the Terminal font!
|

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |