Batch Coding Tutorial I




Introduction: Batch Coding Tutorial I

Batch coding is a very basic programming language that should work on any windows computer ( not apple though ) today I will show you the basics of the programing language.

Step 1: To Start

Open the start menu and type notepad then open notepad and copy the following code into it.

Echo hello

That's it now save the file but save it as anything.bat the file name must end in .bat for this to work. Now open the file there is a lot of junk but the code should say hello
Now right click on the file and select edit change the code to

@echo off
Echo hello

Re open it and there is the word hello
The line "@echo off" will hide any new "junk" (the commands) and "cls" will clear any existing junk.
The two lines can also be combined into one with I will show you in a future tutorial.

Step 2: Echo

Echo would translate to "display the following text"
Echo. Will add a break in the lines ( enter key ) because batch will ignore blank lines
Try experimenting with the echo command for example

@echo off
Echo hello %username% how are you?

Step 3: Pause

Pause will pause the file
Pause>nul will pause the file and hide the words this file is paused.
Commands can be placed after pause as well like bellow

@echo off
Echo hello
Echo how are you?

But here is the problem the file will exit because there are no more commands so for this code have pause at the end.

Step 4: Goto

The goto command goes to a section of the code

@echo off
Echo %random% %random% %random% %random% %random% %random%
Goto top

Save this as matrix.bat and open it
Now the goto command can only goto "top" in this code if a ":" sign is in front of the word top with no space like this :top

Step 5: Set and If

The set command sets environmental variables with can be used if surrounded by percent signs I have used %random% and %username% already now look at the following code

@echo off
Echo How are you?
Set /p feeling=
Echo your feeling %feeling%
If %feeling%==good echo that's good
If %feeling%==bad goto bad
Echo that's bad

Set /p takes the users input and sets it as a variable in this case feeling and if does something with it now try to Make your own code I will release more tuts later for now view my other batch codes here


Be the First to Share


    • Puzzles Speed Challenge

      Puzzles Speed Challenge
    • "Can't Touch This" Family Contest

      "Can't Touch This" Family Contest
    • CNC Contest 2020

      CNC Contest 2020