Introduction: How to Make Some Cool Batch Files

I am new to Instrucatbles. This is my first Instructable. It is about batch coding. I hope you guys like it.

Step 1: Matrix

1:

Open a New Text Document on Notepad.

2:

copy the code below into it:

@echo off
color 0A
title Matrix
:loop
echo 11000011010010100100110101001010100101010101
echo 00111100101101011011001010110101011010101010
goto loop 

3:

go to "File" and click "Save As..."

When the box pops up, type in Matrix.bat (the .bat part is important)

Save it anywhere.

Explanation:

echo off: if you typed "echo hi" the user would only see "hi" not "Echo hi" and on the next line "hi"

color: changes the color

title: changes the title

:loop is a line of code that you can skip too.

echo ____: anything typed after "echo" will be shown in the console window.

goto ___ : goes to the line of code specified

Step 2: Shutdown and Calculator

Shutdown:

1:

Open a New Text File in Notepad

(There are very many Variations of this code, but my favorite and most trollish is

shutdown /f /p

)

2:

Type in

shutdown

3:

You should get a screen with lots of stuff on it. scroll up.

Type in any combination of /_'s or -_'s that you are able to do.

4:

go to "File" and click "Save As..."
When the box pops up, type in Shutdown.bat (the .bat part is important)

Save it anywhere.

Calculator:

1:

Open a New Text Document in Notepad.

2:

Type in:

echo off
:start
cls
set /p math=Equation?
echo Is this your equation? %math%
pause
cls
set /a RESULT=%math%
echo Your answer is: %RESULT%
pause
goto start

4:

go to "File" and click "Save As..."
When the box pops up, type in Calcuator.bat (the .bat part is important)

Save it anywhere.

Explanation:

cls: clears the screen.

set /p ___= : sets player input. Anything after the equals sign (=) is showed in the console window.

set /a ____=__ : Used to set an arithmetic value. set /a result=%math% would mean the result is saved as variable %result% and the variable %math% (which the user set) is the math that the computer does.

pause: Halts all code running until the user presses a button. Displays message "Press any button to continue..."

Step 3: If/If Not Statments

These are kind of complicated.

Example:

echo off
echo 1) Exit
echo 2) test
set /p begin
if %begin% == 1 exit
if %begin% == 2 goto test

:test
echo It Worked!
pause
exit 

Here, if the user set input equals 1, exit.

if the user set input equals 2, it goes to the line ":test".

This can open up to awesome new things, like quiz games and guessing games.

In that example, the user would set the variable %begin% to either 1 or 2.

As for if not, it can open up to guessing games and password programs.

Example:

echo off
echo Hello! type 5-2.
set /p uu
if %uu% == 5-2 goto yay
if not %uu% == 5-2 goto nay

:yay
echo Your answer is: 3
echo Thanks for listening.
pause
exit

:nay
echo YOU DID IT WRONG!
echo HOW DARE YOU NOT LISTEN TO ME!
pause
exit

Here, if you type 5-2, you go to line :yay.

if you type anything else, (if not) you go to line :nay.

Explanation:

If not: If anything else is entered as variable %__%, do the following

if: if _ is entered as variable %__%, do the following

Step 4: Creating (and Adding To) Files

This one is easy to remember.

Example:

echo off
cls
echo Hello!
echo Hello! I bet you didn't see this file coming, did you? > haha.txt
pause
exit

This can open up to cool things like organizing assignments, to-do lists, and a whole lot more.

One cool thing I came up with will come up within the download with everything else at the end.

the way this works, is, in the example, the text "Hello! I bet you didn't see this file coming, did you?" will be copied into file haha.txt in the same folder as this .bat file.

The one > means, if i opened this, and it saved the file, and i changed what it puts into the file saved it file again, it would ONLY say the new words. If you put >> it does not overwrite like that.

Step 5: The End, and Downloading!

Thank you for reading all the way to the end! i hoped this helped those who were looking for cool batch files and those wanting to learn batch coding alike. And i will be making more like this if some people like this.

Download:

Coded Creations

Participated in the
Coded Creations