0

i have an executable filea(.exe) which takes argument from DOS input. I was thinking it would be great while running batch file and it prompt user for input and that input will be set as variable. Unfortunately my not so brilliant idea doesnt work. But im ver sure there's a way. Below is my simple intention

SET /p input=""

cls

(my program).exe %input%

And of course the DOS doesn't translate the variable in this case. Is good enough if someone can enlight me with some link to study on this. Thanks alot in advance

KevinYong
  • 47
  • 1
  • 10
  • check this link: http://stackoverflow.com/questions/14286457/using-parameters-in-batch-files-at-dos-command-line – szpal Mar 03 '15 at 07:41

3 Answers3

1

it's a difference, if you program takes parameters or fetches input from STDIN ("Keyboard")

If it takes parameters, myprogram.exe %input% should work.

If it gets input from keyboard (STDIN), this should help:

echo %input%|myprogram.exe

or let it have it's input from a file:

myprogram.exe <myinputfile.txt

There is a third possibility: myprogram.exe does it's own "keyboard watch". There is no easy pure batch solution for this.

Stephan
  • 53,940
  • 10
  • 58
  • 91
0

Try this:

@echo off

set /p YourParameterValue= Please enter a value now

cls

(your program).exe /YourParameterName %YourParameterValue%

0

Hey guys thanks for answering my question. I got a better answer and it works well for me due to my program requires inputs/arguments from user and as well output a result in a string format.

for /f "usebackq tokens=*" %%i in (`YOUR_PROGRAM.EXE YOUR_INPUT`) do @set VAR1=%%i

echo Output from your program is %VAR1%

It works well too if your program does not require input and you just need an output value from your program.

KevinYong
  • 47
  • 1
  • 10