Click here to Skip to main content
Click here to Skip to main content
Alternative Tip

Get user input from DOS prompt

By , 8 Jan 2011
Rate this:
Please Sign up or sign in to vote.
Not quite, CDMTJX. There are 2 problems with the alternative you posted.
  1. Previous values for uname are not cleared. Running this twice WILL see the previous value
  2. The logic is backwards.
This will work as you intended:
set uname=
SET /P uname="Please enter your name: "
IF "%uname%"=="" (
  ECHO error ...
 ) ELSE (
  ECHO Hello %uname%...


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

About the Author

Jeffrey Buxton
Validity Sensors, Inc.
United States United States
No Biography provided

Comments and Discussions

-- There are no messages in this forum --
| Advertise | Privacy | Mobile
Web02 | 2.8.140415.2 | Last Updated 8 Jan 2011
Article Copyright 2011 by Jeffrey Buxton
Everything else Copyright © CodeProject, 1999-2014
Terms of Use
Layout: fixed | fluid