Click here to Skip to main content
12,242,747 members (65,930 online)
Click here to Skip to main content
Add your own
alternative version

Tagged as

Stats

3.4K views
1 bookmarked
Posted

Get user input from DOS prompt

, 8 Jan 2011 CPOL
Rate this:
Please Sign up or sign in to vote.
Not quite, CDMTJX. There are 2 problems with the alternative you posted.Previous values for uname are not cleared. Running this twice WILL see the previous valueThe logic is backwards.This will work as you intended:@ECHO OFFset uname=SET /P uname="Please enter your name: "IF...
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:
@ECHO OFF
set uname=
SET /P uname="Please enter your name: "
IF "%uname%"=="" (
  ECHO error ...
 ) ELSE (
  ECHO Hello %uname%...
)

License

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

Share

About the Author

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

You may also be interested in...

Comments and Discussions

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