# User Input In Batch



## MariaFY

Hi!

I was wondering if anyone could give it to me real simple..

How can I ask for user input in a batch file, and then use that input in a command?

For instance, say I want give the user the option to enter in a hostname he wants to ping.. How would I prompt that user to enter in a hostname, then use his input with the ping command?

Thanks alot for putting up with stuff like this. :heartlove


----------



## bry623

Will it be a random host name or will it be certain host names??


----------



## dsovic

Batch is usually used for computing without user interaction. All data are in files|DB|cmd line.


----------



## bry623

But if it is set IP's, they can be set up as choice 1,2,3 etc and then the pnging can begin.


----------



## MariaFY

I was thinking of letting the user punch in a random hostname or IP..

If it's necessary to list them and just give the choice, I'd be interested in how this could be done too. :grin: 

Thanks, guys.


----------



## bry623

See if  this helps.

We use a database programming language that allows our users to enter random #'s, so I know that it can be done that way.


----------



## MariaFY

Ah! Just what I needed, bry. Thanks bunches. :girl:

Still not perfected.. But this'll definitely work:

@echo off
cls
echo.
:loop
set choice=
set /p choice=Enter in the target hostname or IP:
ping %choice%
goto loop


----------



## bry623

That's the bad thing about batch, alot of code for a little input. That will definetly work!!


----------

