Hey, that's the geratest! So with ll this brain power AWHFY?
NOTE - For an alternative to notepad download http://buypoe.com/general-programmin...-executor.html
Also, here is a link to another tutorial http://mevaldez.home.mchsi.com/Batch.pdf
Batch files do not really need any programming ability in order to understand.
Batch file programming is used by programmers for many purposes, depending of course on the type of programmer of which you are categorised.
For standard programming, most languages are compiled via command line. Languages compiled by cmd include:
- Java
- C#
- GCC
These are simply the popular languages, however there are still plenty more, I believe nearly every language can be compiled by command line.
Now why would they be used rather than command line? Well the command line interface is not exactly the best looking program around, apart from that You can do more than one command at a time, you don't have to type in the command every time you want to do that action again.
I know when I'm making a Java program I would create a batch file to run it.
C++Code:cd "location" javac myProgram.java pause java myProgram.exe
Now you know why it is used, but more than likely your thinking "why would i use it?".Code:cd "location" cl /clr myProgram.cpp start myProgram
Most commonly batch script is used by internet users for the creation of "virii"
These are simple scripts which (usually) are not malicious.
As most tutorials start off, I'm going to start off with a "Hello world" Application.
But before I do there are a few things you are going to need to know.
There is a keyword called echo, which works two ways depending on how your using it.
You can turn echo on/off via.
orCode:@echo off
This is commonly used at the start of a batch script to remove the Location from the screen of the batch file to make it more presentable when you are wanting it to show text to a user.Code:@echo on
It is case insenesitive, though older programs written it commonly used capitals for keywords simply to easily identify them.
Another way of using it is to display text in the command line interface. It would be done as followed
This is one of the languages with the exception of (" ") quotation marks to store text.Code:echo Hello
The next line you are going to need because once a batch file has run, it exits straight away, which is not very good if you were trying to display text to a user because they wouldn't have enough time to read it (about 2 ms).
The following would wait until the user presses enter
Now you know everything you need to create your own "Hello World" Application.Code:pause
Now i would like to introduce the concept of a label.Code:@echo off echo Hello World pause
It is a line which is used to remember a location in the memory address.
There is no keyword for labels however you must add a ":" at the end, and it must be 1 word (can use underscores)
Now, the next thing which would make sense for you to learn after learning about labels would be the GOTO statement. This is one of the few languages of which it is socially-acceptable to use GOTO.Code:myLabel:
similar to assembly "JMP".
A GOTO statement simply jumps to the defined label. It is commonly used for loops and doing actions upon user input.
It would be done like this
You now should know enough to be able to create the program of which most people learn batch script (to annoy people).Code:goto myLabel
This creates an infinite loop which opens infinite (until the computer crashes or until its closed) command line interfaces.Code:myLabel: start goto myLabel
the "start" keyword is used to start a program.
If you don't specify a program it will just open up command line.
When I first learnt about batch programming I didn't know you could loop in it, I just copy and pasted the word "start" hundreds of time in notepade and saved it as a batch file in order to annoy people.
Similar Threads:
Here's the swag way to use batch.
:start
open notepad
open notepad
open notepad
goto start
There are currently 1 users browsing this thread. (0 members and 1 guests)
Design Sites:
vBulletin Mods
Facebook Covers | Free Facebook Covers
Google Covers | Google Plus Covers
Game Sites:
MMORPG | MW3