Situatie
We are going to learn how to take input from users using Batch Script.
Taking User Input:
@echo off echo Batch Script to take input. set /p input= Type any input echo Input is: %input% pause
Explanation:
- The first ‘echo’ command is used to print a string.
- In the next line, ‘set /p’ command is used to take user input followed by a variable that will hold user input.
Solutie
Pasi de urmat
set /p input= Type any input
- Then for printing the user input we will use ‘%’ on both ends of our variable which is used for holding user input in the previous step.
echo Input is : %input%
- ‘ pause ‘ is used to hold the screen until any key is pressed.
After saving the above code with .bat format. When we will run the file, the below cmd screen will be shown.
In the next step we will provide any input. After pressing enter we will get user input data as Output.
Leave A Comment?