How To: Write Batch!

Write Batch!

Right, So i've been asking alot of questions here on Null-Byte and everyone has been really helpful to me.

So i thought i'd try and give back with one of the first Programing Lang i started with. I know many people of Null-Byte are most likely past the points i am going to talk about but i don't wana skip ahead and then people don't understand the basics!

Right! let's jump into it! Batch is basicly CMD or as some of my older people know it as DOS it's a command line:

So our scripts are basicly CMD/DOS

@Echo off

Let's start off with @Echo off
This command hides all the unwanted "Text" in the console

9 times out of 10 you'll start your script off with that unless you are debugging your script. But we will get into that later.

Echo

echo is print if you've played around with any other programing langue
so what ever you type after "Echo" will be printed to the CMD window!

you can start a cmd window by pressing windowskey+R then typing CMD.

Pointers

now i call theese points but i could be wrong!
Basicly these allow you to jump around in your code
You declare a point with :

anything after ":" will be the point name these are simaller to vars! if you don't know what vars are don't worry about it i'll explain in a later tut. Just remeber that you can not have the same name on two pointers for example

:home
Random Code
:home
Random Code

If you are wanting to jump to a pointer it' simple goto PointerName.

Pause

The pause command is your best freind when it comes to debugging in short it stops the code and waits for user input!

This will prevent your script from closing instantly!

Ending off!

Let's put all the stuff we have learnt and make a basic script real quickly!

Copy that into a notepad of your own and save it as Anything.bat !
ofcourse don't copy the arrows those just comment!

I guess that's it! First lesson and First post on Nul Byte.
Sorry if i am starting really slow. I'll get to more complex stuff asap just hang in there!

Thanks for reading hope it helped in some werid way?

4 Comments

I guess so, Just seem alot of more complex stuff on Null byte so i thought i'd take a poke at the noobs? i guess oh will i'll get more depth with it later.

There are all levels on Null Byte, so this article may be appropriate for some.

The pointers are normally called labels. Same than in C, Perl and other languages

Share Your Thoughts

  • Hot
  • Latest