Knowledge Walls
John Peter
Pune, Maharashtra, India
Things to Know [cont'd]
Prompt value in Things to Know of MS-DOS Commands
5272 Views
How to prompt a value from user in MS DOS batch file? 
SET command is used to set the values to the variable and get a value by prompting the user too on command prompt. By using /p option with SET command requires the value from the user. after equals operator value is used to ask the prompt value from user.

Example
SET /p username=Enter the user name

Hints
/p requires the value from command prompt.
username is the variable name.
Enter the user name is the prompt the message.
Example
@echo off
set /p confirmDeploy=Confirm deployment of code [y/n] ?:
echo %confirmDeploy%
Output 
Confirm deployment of code [y/n] ?:n
n
Addition using prompting two values?
@echo off
SET /p a=Enter the a value:
SET /p b=Enter the b value:

SET /a c=a+b

echo %c%
Output 
Enter the a value: 10
Enter the b value: 20
30
Next Topics
Next lessons of current book.
Decision making of MS-DOS Commands
Decision making of MS-DOS Commands
Decision making of MS-DOS Commands
Decision making of MS-DOS Commands
File System of MS-DOS Commands
Previous Topics
Previous lessons of current book.
Things to Know of MS-DOS Commands
Best Lessons of "MS-DOS Commands"
Top lessons which are viewed more times.
Arithmetic Operators of MS-DOS Commands
Arithmetic Operators of MS-DOS Commands
String manipulation of MS-DOS Commands
Relational Operators of MS-DOS Commands
String manipulation of MS-DOS Commands
String manipulation of MS-DOS Commands
Things to Know of MS-DOS Commands
  Copyright © 2014 Knowledge walls, All rights reserved
KnowledgeWalls
keep your tutorials and learnings with KnowledgeWalls. Don't lose your learnings hereafter. Save and revise it whenever required.
Click here for more details