Wednesday, 11 January 2012

Batch File Basics

A batch file is a text file containing a series of commands that you might use in everyday computing used in command prompt in order to perform an action. The most common uses are to start programs and to run utilities. Batch files do that with one command instead of the multiple commands usually required. They can be made as shortcuts so that multiple commands may be executed at one click.

To start, open a Notepad or Wordpad document.

Lets try a simple batch command. type:
"@echo off
echo first test
pause"
Save as file.bat
@echo off –  you would usually put this at the beginning of your files. It means that the program won’t show the command that you told it to run while it’s running – it’ll just run the command.
The pause command tells it to wait for the user to press a key before continuing,the result should look like : 
Batch files can also be used to open webpages , eg opening hackinland.blogspot.com via internet explorer.
Open a new document,and type :
"@echo off
start iexplore.exe www.hackinland.blogspot.com"
Having a pause command at the end of the script and using the echo command instead of @echo off is optional,i recommend using echo instead of @echo off and adding a pause at the end of the script for people who are using this script for the first time because it will show the commands whilst doing them.