Posted By

MMDeveloper on 05/13/09


Tagged

input variable dos user


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

Tyster


Simple MSDOS User Input Variables


 / Published in: DOS Batch
 

This seems to be a frequently asked question at my job so I've decided to setup a simple dos batch file that accepts user input

  1. @echo off
  2.  
  3. :GETINPUT
  4. set /p name=What is your name?:
  5. set /p confirmCaseSensitive=Are you sure [y/n]?:
  6. if "%confirmCaseSensitive%"=="" (GOTO GETINPUT)
  7. if "%confirmCaseSensitive%"=="y" (GOTO NEXTSTEP) else (GOTO EXIT)
  8.  
  9. :NEXTSTEP
  10. echo your name was: %name%
  11. set /p repeatCaseInsensitive=Repeat Process [Y/y/N/n]?:
  12. if "%repeatCaseInsensitive%"=="" (GOTO GETINPUT)
  13. if /I "%repeatCaseInsensitive%"=="y" (GOTO GETINPUT) else (GOTO EXIT)
  14.  
  15. :EXIT

Report this snippet  

You need to login to post a comment.