Would you like to learn how to prompt for user input using the command line? In this tutorial, we are going to show you how to use the command line to request input to Batch scripts on a computer running Windows.

• Windows 2012 R2
• Windows 2016
• Windows 2019
• Windows 10
• Windows 7

Equipment list

Here you can find the list of equipment used to create this tutorial.

This link will also show the software list used to create this tutorial.

Windows Related Tutorial:

On this page, we offer quick access to a list of tutorials related to Windows.

Batch Script – Prompting for user input

Start a command-line prompt.

Windows - Command-line prompt

Request a user input using the command line.

Copy to Clipboard

Display the user input.

Copy to Clipboard

In our example, the user input was stored in a variable named MYNAME.

On the notepad application, create a Batch script named TEST.

Copy to Clipboard

Here is the script result.

Copy to Clipboard

Congratulations! You are able to request user input using Batch scripts.

Batch script – Prompting for user input using a function

Start a command-line prompt.

Windows - Command-line prompt

Create a function to request the user input.

Copy to Clipboard

Call the function of the Batch script.

Copy to Clipboard

In our example, we created a function named MYPING.

On the notepad application, create a Batch script named TEST.

Copy to Clipboard

Here is the script result.

Copy to Clipboard

Congratulations! You are able to prompt a user for input using a Batch script function.