Results 1 to 4 of 4
  1. #1
    Senior Member
    Devereux is offline

    Posts
    266

    Basic Batch Programming

    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.

    Code:
    cd "location"
    javac myProgram.java
    pause
    java myProgram.exe
    C++

    Code:
    cd "location"
    cl /clr myProgram.cpp
    start myProgram
    Now you know why it is used, but more than likely your thinking "why would i use it?".

    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.

    Code:
    @echo off
    or
    Code:
    @echo on
    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.

    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

    Code:
    echo Hello
    This is one of the languages with the exception of (" ") quotation marks to store text.

    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

    Code:
    pause
    Now you know everything you need to create your own "Hello World" Application.

    Code:
    @echo off
    echo Hello World
    pause
    Now i would like to introduce the concept of a label.
    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)

    Code:
     
    myLabel:
    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.

    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
    Code:
    goto myLabel
    You now should know enough to be able to create the program of which most people learn batch script (to annoy people).

    Code:
    myLabel:
    start
    goto myLabel
    This creates an infinite loop which opens infinite (until the computer crashes or until its closed) command line interfaces.

    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:



  2. #2
    Unregistered Guest
    Hey, that's the geratest! So with ll this brain power AWHFY?


  3. #3
    Junior Member
    elliottedgar87 is offline

    Posts
    0
    Batch is very good. Combined with vbs it can do really cool stuff.


  4. #4
    B-A-N-N-E-D
    ne0_sp00f3r is offline

    Posts
    0
    Here's the swag way to use batch.

    :start
    open notepad
    open notepad
    open notepad
    goto start


Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Copyright © 2009-2012 BuyPoe.com All Rights Reserved.

Design Sites:
vBulletin Mods
Facebook Covers
| Free Facebook Covers
Google Covers | Google Plus Covers

Game Sites:
MMORPG
| MW3