Creating Batch Script with User Input

29 May 2022

Batch Script supports the concept of command line arguments where arguments can be passed to a batch file when called.

Using the /p switch and the SET command, you can define variables from an Input.

/p switch allows you to set the value of a variable to the input line entered by the user.

The following script is an example of getting input from the user using the keyboard.

@echo off
echo Enter your variable : 
set /p variable=
echo Your variable is %variable%

The result of the script

TOP TUTORIALS:  How to Add TPM (Trusted Platform Module) to VMWare Virtual Machine

You can simplify the script to .

@echo off
SET /P variable=Enter your variable :
echo Your variable is %variable%