Get user input Batch files

Thread Starter

Anthony Quah

Joined Dec 1, 2007
80
hi guy,

I am doing some batch files...can I know what is the format to get input from user ...example the user enter 1 will direct to folder A or user enter 2 will direct to folder B..I am have problem to define the variable and string...this is just my hobby to learn a batch files...any suggestion or format i can refer? thanks
 

SgtWookie

Joined Jul 17, 2007
22,230
There IS no apparatus provided for input of parameters.

However, you can retrieve parameters that were passed on the command line.
%0 - returns how the batch file was invoked
%1 thru %9 - returns the individual parameters
SHIFT - causes %0 thru %9 to shift down 1.

Example:

C:\>type t.bat
echo %0
echo %0 %1 %2 %3 %4 %5
SHIFT
echo %0 %1 %2 %3 %4 %5

C:\>T a b c d e f g

C:\>echo T
T

C:\>echo T a b c d e
T a b c d e

C:\>SHIFT

C:\>echo a b c d e f
a b c d e f
C:\>
 

RiJoRI

Joined Aug 15, 2007
536
THere were a number of user-input commands written when DOS was The System. I do not remember the names, however. :(

THe OP may wish to look into alternate shells, such as NDOS, 4DOS, etc.

--Rich
 
Top