Command line: how to use the content of a text file as an input argument to a program in windows?

StackOverflow https://stackoverflow.com/questions/22389370

Pregunta

In one directory I have two files:

'program.exe' and 'content.in'

How do I start 'program.exe' with the content of 'content.in' as an argument from the command-line in windows ?

Thanks.

¿Fue útil?

Solución 2

If 'program.exe' accepts input from standard in you would

program.exe < content.in

If it doesn't then you are dependent on the program processing files through command arguments, potentially like

program.exe content.in

or

program.exe -i content.in

Otros consejos

You can also accomplish this by putting the contents of the file into a variable, borrowing the second half of this answer.

set /p VV=<content.in
program.exe %VV%

You probably want

for /F "tokens=*" %i in ('content.in') do program.exe %i

(In a batch file, replace %i with %%i.)

Note that if content.in contains more than one line of text, program.exe will be run multiple times, once for each line.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top