Link to home
Start Free TrialLog in
Avatar of ashok73
ashok73

asked on

How to accept Input in Batch file

I have a batch file in that i want the user to key in the input , Store it in a variable and then do the processing...
For example
C> abc.bat
It should ask "Enter Source Directory"

Thanks in Advance.

Avatar of dimitry
dimitry

In DOS the simplest way to pass some data to batch file is
to use command line parameters.
For example if you want to pass source directory to the batch file, you need to do:
 abc.bat c:\srcdir
and in batch file you can use %1 as variable with value c:\srcdir
Avatar of ashok73

ASKER

Thanks for the comment . But is it possible to have accepting kind of facility in Batch file ????
I heard there is a command called Choice , Is it correct ???
Choice.com is DOS utility that "knows" how to return diferent error level according to the answer.
For example:
 choice (you get [Y/N] and you need to push Y or N)
 IF ERRORLEVEL 2 GOTO noAnswer
 ... (yes answer)
 GOTO end
:noAnswer
 ... (no answer)
:end
ASKER CERTIFIED SOLUTION
Avatar of rin1010
rin1010

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of ashok73

ASKER

rin1010 Thanks for your help.
thanks to Dimiltry as well..

Bye.


Avatar of ashok73

ASKER

rin1010 Thanks for your help.
thanks to Dimiltry as well..

Bye.



You're most welcome, ashok...
btw... Was the B grade the default
or are my comments somehow deficient?