This site uses cookies! Learn More

This site uses cookies!

For providing our services, we do use cookies.
But get used, this is what most of modern web do!
However we have to warn you since we are obligated to so due to EU laws.

By continuing to use this site, you agree to allow us to store cookies on your computer. :)
And no, we will not eat your computer nor you will be able to eat those cookies :P

Sign in to follow this  
Followers 0
komaya

some example for BAT IF statement

3 posts in this topic

*.BAT or *.CMD files are simple but very useful.

below code is that take user's input and judgement it.


REM user choice is saved in variable %YESNO%

:RETRY
SET /p YESNO="Yes or No ? (y/n) : "

IF /I NOT "%YESNO% == "y" IF /I NOT "%YESNO%" == "n" (
   ECHO only y or n is permited, try again
   GOTO RETRY
)

REM do anything here ( for y or n)

Reference site:

A Windows Batch File Programming Primer - http://www.vectorsite.net/tsbatch.html

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0