Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to pass input to .exe in batch file?

I have a .exe which requires 3 integers as input. For example:

myCode.exe < input.txt

In input.txt:

2
3
8

Now I want to put the command in a batch file. how can I write the batch file? (Here I want to pass 3 fixed integers in the batch file)

THANKS!

like image 866
Helen Avatar asked Sep 24 '13 02:09

Helen


People also ask

How do you run a .EXE file from a batch file?

Create Batch File to Run EXESave your file with the file extension . bat , e.g. run-exe-program. bat and double click on it to run the .exe program.

Can a batch file ask for input?

You are able to prompt a user for input using a Batch script function.

How do I run an EXE from command line arguments?

Every executable accepts different arguments and interprets them in different ways. For example, entering C:\abc.exe /W /F on a command line would run a program called abc.exe and pass two command line arguments to it: /W and /F.

Is .EXE a batch file?

EXE files are different from BAT files since they contain executable binary data rather than plain text commands. They are stored in the Portable Executable (PE) format. The EXE file format includes various headers and sections that tell Windows how to run a program.


2 Answers

try this:

run.bat:

myCode.exe %1 %2 %3

call example:

run.bat 111 222 333

and with file:

run.bat < input.txt

like image 56
msangel Avatar answered Sep 23 '22 16:09

msangel


This may also work:

(
echo 2
echo 3
echo 8
) | mycode.exe
like image 45
foxidrive Avatar answered Sep 21 '22 16:09

foxidrive