Saturday, March 2, 2013

BEGINNERS GUIDE TO BATCH PROGRAMMING


Hi Friends, Welcome to (HACKING begins - "An approach to introduce people with the truth of HACKING"), In this article I'll tell you about BATCH file (.bat) programming. According to Wikipedia : a batch file is a text file containing a series of commands intended to be executed by the command interpreter.
In this article I'll introduce you with the basic of batch file and developing of batch programmes.

Batch file programming is nothing but the windows version of Unix Shell programming. In MS-DOS, a batch file can be started from the command line by typing its name (along with any required parameters) and pressing the "enter" key. When MS-DOS loads, the file AUTOEXEC.BAT is automatically executed, so any commands that need to be run to set up the MS-DOS environment for use could be placed in this file.

Why we need batch file programs ?
When we need to execute a set of commands over and over again to perform a routine task like backup files, Del temp files, then there is very difficult to type the same set of command over and over again, batch files are used.

Creation of batch file :
Batch files are basically plain text file containing DOS command. You can edit or write your batch file with notepad or DOS editor(EDIT). Always remember that a batch file should have an extension.BAT. Firstly you have to learn how you can change directory in DOS.
  1. MD A (Make directory "A")
  2. CD A (Change directory to "A")
  3. CD.. (Back to previous directory)
  4. CD\ (Back to c:\> directory automatically)
Command used in DOS to make batch file
  •  ECHO
The ECHO command is used as a printing tool, this is used to display something on screen. It can be used to tell the user what the batch file is currently doing. to prevent DOS from displaying the command being executed , simply add ECHO OFF command in batch file, but it still shows the initial ECHO OFF command. To hide the even ECHO OFF command, simply replace the first line with @ECHO OFF.
examples: 
echo ON{Restores normal display activity.}
echo OFF{Halts display of DOS prompt and commands.}

  • REM
The command REM or Remark is the basic command of batch file, it is used by programmers to insert the comment into their code. Don't place REM command overload in batch file, it effect  your execution speed to run your file. This command is basically used in huge batch files.
examples:
@rem {Hides the remark from display.} 
  • PAUSE
This is also an effective command in batch file programming,  some time before deleting all files of a folder, you need to give user time to react or change his mind then PAUSE command is used to hold the working of process.
examples:
pause {Displays "Press any key to continue ...".}
  • GO TO
GOTO command is a looping command, used to execute an operation up to infinity loop or for some conditions, GOTO Transfers control within a batch file to a line identified by a label. The label must be of the form ":LABEL".
 examples:
goto LABEL
:LABEL 
(you can replace label with any name you want)

  •  CLS
Clears the video display screen, setting the cursor in the upper left-hand corner. This command is used to clear the scree. Command : CLS.
  • IF [Conditional Branching]
The IF command is very useful command that allow us to make the batch file more intelligent and usefully. Using this command, one can make batch programs check the parameter and accordingly perform a task. IF command is used for checking the condition true or false.
Syntax : IF [NOT] EXIST FILENAME command
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

A program to to check the existence of a file (Example)
@echo off
CLS
IF EXIST c:\>abc.dos GOTO PRINT
GOTO end
:PRINT
ECHO FILE EXIST 
:END
This is just an overview to guide you with BATCH programming, shortly i make an post with some batch programs by which you can also make prank or fake virus in batch programming.


No comments:

Post a Comment

Chat Without Save Number WhatsApp Trick

  There is cool trick here, You can chat to anyone without saving anyone's number in contact list. Wa.me/+910000000000 Just add anyone...