OK, I'm going to assume that you already have batch experience and don't need me to explain every command and every symbol and every thing that is typed. So here we have four
different batch files. If you have no experience with batching, I suggest you try this tutorial:
https://www.instructables.com/id/Batch-Tutorial-Using-Batch/
Here is the code for testing colors. It's simple and it can be pretty useful.
@echo off
:test
help color
echo ----------------------------------------------------------
echo.
echo Type a color code to test colors.
echo To exit, just press the X.
set/p color=
color %color%
goto test
In the zip. folder in the last step, I give you a portal that goes to instructables.com.
But here, I will show you a batch file that you can customize to go to multiple websites.
Here it is:
@echo off
color 0a
echo This is the site locater. Choose the # of the site you would like to go to.
echo 1= www.youtube.com
echo 2= www.facebook.com
echo 3= www.internet explorer.com
echo 4= www.firefox.com
echo 5= www.hulu.com
echo 6= www.netflix.com
echo.
set/p "number=-->"
if %number%==1 GOTO 1
if %number%==2 GOTO 2
if %number%==3 GOTO 3
if %number%==4 GOTO 4
if %number%==5 GOTO 5
if %number%==6 GOTO 6
:1
start www.youtube.com
goto end
:2
start www.facebook.com
goto end
:3
start www.internetexplorer.com
goto end
:4
start www.firefox.com
goto end
:5
start www.hulu.com
goto end
:6
start www.netflix.com
goto end
:end
You may replace the listed websites with any of your own if you want.
This is a guessing game I came up with.
I did not take some other guy's guessing game and make some changes.
This one is rather of its own design.
@echo off
color 0b
set/a one's=50
set/a two's=40
set/a three's=30
set/a four's=20
set/a five's=10
set/a six's=5
set/a seven's=1
echo Welcome to this useless two-player game in which one player picks a number
echo.
echo between 1 and 100 and the other player tries to guess it. Player 1 makes the
echo.
echo number and player 2 tries to guess it. You will be given NO hints or clues.
echo.
pause
cls
echo Enter the name for each player.
set/p "pone=Player one>"
echo.
set/p "ptwo=Player two>"
cls
goto ar
:busted
cls
echo I SAID a number between 1 and 100!
echo.
:ar
echo OK %ptwo%, look away. %pone%, type in the number and press enter.
set/p "deguess=>"
if %deguess% GTR 100 GOTO busted
cls
echo Choose a difficulty, %ptwo%:
echo.
echo (1) piece of cake-50 guesses
echo (2) easy-40 guesses
echo (3) moderate-30 guesses
echo (4) a little tricky-20 guesses
echo (5) hard-10 guesses
echo (6) insane-5 guesses
echo (7) impossible!-1 guess
echo.
echo Type the number of the difficulty you would like to play.
echo.
set/p "diff=>"
if %diff%==1 GOTO 1
if %diff%==2 GOTO 2
if %diff%==3 GOTO 3
if %diff%==4 GOTO 4
if %diff%==5 GOTO 5
if %diff%==6 GOTO 6
if %diff%==7 GOTO 7
:1
cls
goto br
:no21
cls
echo NOPE!
echo.
:br
echo Guess in the space below. You still have %one's% guesses.
set/p "guess41=>"
if %guess41%==%deguess% GOTO success
set/a one's=%one's%-1
if %one's%==0 GOTO failure
goto no21
:2
cls
goto cr
:no22
cls
echo NOPE!
echo.
:cr
echo Guess in the space below. You still have %two's% guesses.
set/p "guess42=>"
if %guess42%==%deguess% GOTO success
set/a two's=%two's%-1
if %two's%==0 GOTO failure
goto no22
:3
cls
goto dr
:no23
cls
echo NOPE!
echo.
:dr
echo Guess in the space below. You still have %three's% guesses.
set/p "guess43=>"
if %guess43%==%deguess% GOTO success
set/a three's=%three's%-1
if %three's%==0 GOTO failure
goto no23
:4
cls
goto er
:no24
cls
echo NOPE!
echo.
:er
echo Guess in the space below. You sill have %four's% guesses.
set/p "guess44=>"
if %guess44%==%deguess% GOTO success
set/a four's=%four's%-1
if %four's%==0 GOTO failure
goto no24
:5
cls
goto fr
:no25
cls
echo NOPE!
echo.
:fr
echo Guess in the space below. You still have %five's% guesses.
set/p "guess45=>"
if %guess45%==%deguess% GOTO success
set/a five's=%five's%-1
if %five's%==0 GOTO failure
goto no25
:6
cls
goto gr
:no26
cls
echo NOPE!
echo.
:gr
echo Guess in the space below. You have %six's% guesses left.
set/p "guess46=>"
if %guess46%==%deguess% GOTO success
set/a six's=%six's%-1
if %six's%==0 GOTO failure
goto no26
:7
cls
echo Guess in the space below. You only have %seven's% guess.
set/p "guess47=>"
if %guess47%==%deguess% GOTO success
goto failure
:success
cls
echo Well done, %ptwo%! You may now exit the game.
color 0c
color 09
color 0e
goto success
:failure
cls
echo %pone%'s number was too difficult. Sorry, %ptwo%.
echo.
echo The number was %deguess%.
echo.
pause
A simple timer with a built-in calculator.
@echo off
:menu
color 0b
:bust
cls
echo Welcome to the timer. This timer only counts seconds.
echo.
echo Type in the amount of seconds to count. The number may range from 0 to
echo 99,999. If you need help converting minutes into seconds, type c for a
echo caculator.
echo.
set/p "time=>"
if %time%==c GOTO calc
if %time%==C GOTO calc
if %time% GTR 99999 GOTO bust
cls
echo The time has been set! Press any key to start counting. You can stop the
echo timer by pressing any key. After stoping, the timer cannot continue.
echo.
pause
cls
color 0c
timeout %time%
echo.
echo (DING!)
echo.
pause
goto menu
:calc
cls
color 0a
echo Type the math problem below. This calculator doesn't accept decimals,
echo percents, etc. Only whole numbers.
echo.
set/p "math=>"
set/a nmath=%math%
cls
echo %math%=%nmath%
pause
cls
echo Would you like to return to the timer or use the calculator again?
echo.
echo c or C= calculator
echo t or T= timer
echo.
set/p "route=>"
if %route%==c GOTO calc
if %route%==C GOTO calc
if %route%==t GOTO menu
if %route%==T GOTO menu
P.S.
If anyone knows how, I'd like to know how to make some noise sound out when the timer
goes off. But only for a short time. I don't want to have it go on infinitely, because that would mean restarting the computer every time I use the timer.
**************************
Attachments -->
If you don't know what batch files are, this is the perfect tutorial! Just copy the text onto notepad and save as "Batch Tutorial.bat" (Don't type quotation marks!)
You could also just download it on the next step.
@echo off
title My Batch Tutorial
color 0a
echo ------------------------------------------------------------------------
echo Welcome to my tutorial! Here I will tell you all I know about batch files.
echo ------------------------------------------------------------------------
echo.
pause
cls
echo A batch file is a mini program. They are fun and easy to make.
echo.
echo (sometimes)
echo.
echo In fact, this is a batch file!
echo.
pause
:to
cls
echo -Basic Commands
echo.
echo Here are some commands. Type down the one you want to learn about.
echo.
echo When typing, DO NOT type spaces. If I were you, I'd take these in order.
echo.
echo set, set/a, set/p, echo, @echo off, cls, color, pause, goto
echo.
set/p learn=
if %learn%==set/a GOTO sa
if %learn%==set/p GOTO sp
if %learn%==set GOTO se
if %learn%==echo GOTO e
if %learn%==@echooff GOTO eo
if %learn%==cls GOTO c
if %learn%==color GOTO co
if %learn%==pause GOTO p
if %learn%==goto GOTO g
:se
cls
echo Open notepad. (all programs/accessories/notepad)
echo.
echo The first thing you need to know is what a variable is. A variable is a piece of information that the computer stores for later.
echo.
echo In notepad, type:
echo.
echo set num1=hi!
echo.
echo The command "set" stores num1 in the computer. Num1's carrying the message "hi!"
echo.
echo So every time we type num1, Hi! appears, right?
echo.
echo WRONG
echo.
echo To do that, we need to type:
echo.
echo @echo off
echo set num1=hi!
echo echo %%num1%%
echo pause
echo.
pause
cls
echo Don't worry about echo, @echo off, and pause. We'll talk about those later.
echo.
echo Notice that instead of typing num1 I typed %%num1%%.
echo.
echo To make this a batch file, click file/save as. When you save be sure to type
echo .bat at the end. This is what makes it a batch file. When you run it,it should
echo say:
echo.
echo hi!
echo press any key to continue...
echo.
echo -----------------------------------------------------------------------
echo.
pause
goto to
:sa
cls
echo Now that you know the basics of sets, let's get a little more complicated.
echo.
echo So you know that sets store info, right? What if I wanted to do math?
echo.
echo Type this in notepad.
echo.
echo @echo off
echo set num=1
echo set num=%%num%%+1
echo echo %%num%%
echo pause
echo.
echo After you save it as .bat, run it.
echo.
echo But before that, predict what will be displayed.
echo.
echo So if num=1, then num=%%num%%+1, it should say 2,right?
echo.
echo To find out, run the program.
echo.
pause
cls
echo It said 1+1, didn't it? That's because the computer took your command literaly.
echo.
echo To make your command mathematical, you need to type:
echo.
echo @echo off
echo set/a num=1
echo set/a num=%%num%%+1
echo echo %%num%%
echo pause
echo.
echo After you save it with .bat at the end, run it.
echo.
echo Now it should display 2.
echo.
echo That's because we used set/a. The set/a command makes a set that takes your
echo input mathematicly.
echo.
pause
goto to
:sp
cls
echo This is the last portion of the set tutorials.
echo.
echo The set/p command lets the user name what a variable holds.
echo.
echo For example, I used the set/p command on this tutorial so you could
echo choose what you wanted to learn about.
echo.
echo With the set/p command comes the if command.
echo.
echo The if command lets you have two or more different places to go.
echo.
echo Type this in notepad.
echo.
echo @echo off
echo echo Press 1 to say hi or press 2 to say bye.
echo set/p go=
echo if %%go%%==1 ECHO Hi!
echo if %%go%%==2 ECHO Bye!
echo pause
echo.
echo ------------------------------------------------------------------------
echo.
pause
cls
echo Save it as .bat and run the file.
echo.
echo Basicly how this works is set/p waits for you to type in info for "go" to hold.
echo.
echo Then, the if command ensures that if "go"=1, say Hi! And if "go"=2 say bye!
echo.
echo Yes, you have to type two equal signs.
echo.
pause
goto to
:e
cls
echo By now, you've probably guessed what echo does.
echo.
echo But if you haven't, let me explain.
echo.
echo The echo command lets you display a message.
echo.
echo In notepad, type:
echo.
echo @echo off
echo echo Type a math problem to solve!
echo set/p math=
echo set/a newmath=%%math%%
echo echo %%newmath%%
echo pause
echo.
echo Save it as .bat and run the program! You've just made a caculator!
echo.
pause
cls
echo Here are some tips and facts on echo:
echo.
echo -Be sure to put a space after echo
echo -If you type echo. you'll get a blank row
echo -Anything you type after echo will not take effect unless it's a set
echo -To type a set after echo and not make it have an effect, type
echo %%%variablename%%% on each side, or just type without %%'s.
echo.
pause
goto to
:eo
cls
echo You also may have guessed what this command does.
echo.
echo However, this one is harder to predict.
echo.
echo Type this in notepad.
echo.
echo echo Type a math problem to solve!
echo set/p math=
echo set/a newmath=%%math%%
echo echo %%newmath%%
echo pause
echo.
echo As you can see, this is the caculator from the previous lesson, but without the @echo off command.
echo.
echo Try the program!
echo.
pause
cls
echo It did the same thing as the other caculator, but there was a whole lot more
echo computery stuff shown.
echo.
echo The @echo off command hides all of that.
echo.
echo It is not a mandatory command in a batch file,but it helps a lot in any program.
echo [It really, REALLY helps]
echo.
pause
goto to
:c
cls
echo The cls command clears out the entire page like a dry-erase board.
echo.
echo An example of the cls command is in this very lesson!
echo.
echo To see it, proceed.
echo.
pause
cls
echo See? The page was "erased" and replaced with new text!
echo.
echo Type this in notepad. Type an insult where it says, "TYPE INSULT HERE."
echo.
echo @echo off
echo set pi=[TYPE INSULT HERE]
echo echo %%pi%%
echo echo Press 1 to make this message go away.
echo echo Press 2 to make this message repeat itself 8 times.
echo set/p choo=
echo if %%choo%%==1 GOTO over
echo if %%choo%%==2 ECHO %%pi%%%%pi%%%%pi%%%%pi%%%%pi%%%%pi%%%%pi%%%%pi%%
echo pause
echo goto end
echo :over
echo cls
echo pause
echo :end
echo.
echo Pretty funny, eh? Anyway, this is is related to the lesson because the cls
echo command was used to make the insult disapear.
echo.
pause
goto to
:co
cls
echo I bet by now you're wondering how I got colored text.
echo.
echo The answer is the "color" command!
echo.
echo OK, a lot of stuff is about to show up. I didn't type down what you are about to see.
echo.
echo I used the "help color" command.
echo.
pause
cls
help color
echo ________________________________________________________________________
echo.
echo Told 'ya!
echo.
echo To test colors, type this in notepad.
echo.
echo @echo off
echo :test
echo help color
echo echo ------------------------------------------------------------------------
echo echo.
echo echo Type a color code to test colors!
echo set/p chrome=
echo color %%chrome%%
echo goto test
echo.
echo That program should help you test out color combos!
echo.
pause
goto to
:p
cls
echo To find out what pause means, type this in notepad:
echo.
echo @echo off
echo echo Hi! My name is Bob!
echo.
echo Test the file.
echo.
pause
cls
echo Too fast!
echo.
echo To let yourself actually read the text, add this to your notepad code.
echo.
echo @echo off
echo echo Hi! My name is Bob!
echo pause
echo.
echo The pause command made "press any key to continue..." appear.
echo.
echo This lets you type text without it disappearing as soon as you open the file.
echo.
pause
goto to
:g
cls
echo The goto command is also pretty easy to guess.
echo.
echo This command lets you go to a certain place in the file.
echo.
echo Type this in notepad.
echo.
echo @echo off
echo color 0a
echo echo Press 1 for info about 1 or 2 for info about 2.
echo set/p me=
echo if %%me%%==1 GOTO one
echo if %%me%%==2 GOTO two
echo :one
echo cls
echo The numeral value of a single object, being, etc.
echo pause
echo goto end
echo :two
echo cls
echo The numeral with a value of 2.
echo pause
echo :end
echo.
pause
cls
echo I bet you understand what's going on here.
echo.
echo To make the p.c. go somewhere, you have to put : before the location.
echo.
pause
goto to
Attachments -->
Very nice tutorial...just an advice to make it better
after the choises in the begining you d'better add :
(I have copied some stuff from before so you can understund.Te bold is what you have to add)
set/p learn=
if %learn%==set/a GOTO sa
if %learn%==set/p GOTO sp
if %learn%==set GOTO se
if %learn%==echo GOTO e
if %learn%==@echooff GOTO eo
if %learn%==cls GOTO c
if %learn%==color GOTO co
if %learn%==pause GOTO p
if %learn%==goto GOTO g
echo.
cls
echo Invalid value = %learn%
echo.
pause
cls
goto :to
This is because typing a wrong word in the choices it makes you go to your last awnser to the question.Try it......