loading

Welcome to my first instructable ever. My name is Batch4Life and I will be making instructables on how to write batch files. I will try my best to go in depth because learning how to write batch files for me was tough because it is a lot of learning by yourself. I will start from the bone basics and teach from there so you have a strong foundation.

Step 1: Starting Out

You need to open notepad.exe. You can open notepad by right clicking on your desktop and then clicking New -> New Text Document. Set the name as "Lesson 1"

Step 2: Build the Program

@echo off

This is the first thing you want to put type in the document. It will be used at the top of almost everything you will ever make. What is does it makes it so that the directory of where the command is being executed from is hidden or made invisible. This makes the whole thing look a lot cleaner.

Step 3: Color

@echo off

color a

The default color for windows command prompt is white text on a black background. color a changes the color to a light green text. I almost always change the color in my files to make them more visible to read. For a list of colors you can choose from refer to the picture above. The picture also has additional instructions to change the background.

Step 4: Printing Text

@echo off

color a

echo Hello!

The line "echo Hello!" prints the text "Hello!" on the command line. It will be in which ever color that you specified before. You can make it print what ever you want as long as you have a space after echo. To print a completely blank line, you type "echo." Ex.

@echo off

color a

echo 1

echo.

echo 2

Would have the output

1

(Blank line)

2

Step 5: Pausing

@echo off

color a

echo Hello!

pause

The line that has "pause" on it pauses the batch file and outputs the line "Press any key to continue..." This is so you can see what you printed without it just instantly closing on you. To make the "Press any key to continue..." invisible to make a clean look you add a ">nul" to the back. It would look like this...

@echo off

color a

echo Hello!

pause>nul

Step 6: Finish!

@echo off

color a

echo Hello!

pause>nul

You have now written your first batch file. I am sure it took me a lot longer to write this then it did for you to read it so I hope you enjoyed. I will be creating future lessons if this one gets noticed.

-Batch4Life

Really nice and simple im looking into batch
<p>Be sure to follow for future Lessons!</p>
I will be following these 'ibles!

About This Instructable

1,944views

20favorites

More by Batch4Life:Command Prompt Lesson 2 Command Prompt Lesson 1 
Add instructable to: