How to Prompt User Input and Use Results in Batch Script
This tutorial will show how to take user input and use the results in another command using Batch Script.
Prompt User Input and Use Results in Batch Script
The general format of the code to take user input is shown below.
set /p VARIABLE="INSTRUCTIONAL STRING"
Let’s see an example. The below code will take a user name and show the name as output.
@echo off
set /p name="Enter your name: "
echo Your name is: %name%
Output:
Enter your name: Alen
Your name is: Alen
Here, we used the instructional string Enter your name
. This part is optional.
You can include this to instruct users about what they need to enter in this field. And remember that the method we discussed above is only for Windows CMD.
Aminul Is an Expert Technical Writer and Full-Stack Developer. He has hands-on working experience on numerous Developer Platforms and SAAS startups. He is highly skilled in numerous Programming languages and Frameworks. He can write professional technical articles like Reviews, Programming, Documentation, SOP, User manual, Whitepaper, etc.
LinkedIn