I was learning about batch file programming and making this
paper so that i could remember the commands but this paper
solely taken the form of tutorial.Well it isnt completed yet but i
will provide soon the complete text.
So here it goes
Well batch file is the easiest way to implement and run set of
DOS commands by just running a single file.Batch files can be
easily made and edited using any of the text editor (I preffer
using notepad because i use it :-)
Simply if you want to read the code of the batch file open it in
notepad or select edit option by right clicking on it. and if you
want to create one batch file write code in notepad and SAVE AS
file as xxx.bat. The main thing is to make it .bat extension.
Codes which can be used in batch files.
According my current knowledge every command which can be
use in DOS can be used in a batch file.
if you want to run dir command then the code for batch
file will be as follows:
After writing this in notepad save it whatever.bat andCode:dir
when you run it,a dos window will appear and you can see the
directory structure of that directory where whatever.bat is
placed. Now if you want to look at the other dirctory say windows
then code will be
Here "cd c:\windows\" will switch us to windows folderCode:cd c:\windows\ dir /p
and "dir /p" will show the files and folders.( /p at the end of dir
stands for showing files and folders page wise)
Now there is another facility through which instead of
displaying output it can save the output to a file.This is done as :-
This will create a text file named as "info" at C: driveCode:dir > c:\info.txt
which contain the detail files and folders of the directory where
the batch file is executed.
This will show whatever you write after it.
the first line shows where the batch file is placedCode:C:\WINDOWS\Desktop>echo hi hi
followed by command executed.
You can create the fake error message just for fun.
OUTPUTCode:echo This program uses to much resourses.Please shut down windows now.
but any one can easily understand that it is a fakeCode:C:\WINDOWS\Desktop>echo This program uses to much resourses.Please shut down windows now. This program uses to much resourses.Please shut down windows now.
message by reading first line.
Well one can hide first line i.e path and command
executed simply by adding "@" before any command.It just dont
shows the path and the command executed.It can be applied
approximately on every command.
OUTPUTCode:@ echo Welecome to Dos
If echo command is followed by off keyword (i.e "echoCode:Welcome to Dos
off") then nothing will be displayed and the dos window will
appere only for a sec or less than a sec.
Well this command will be very useful its importance is
discussed later in this article.
4. md and rd
This is stand for make directory and remove
directory.The syntax is simple "md name" AND "rd
name".Here "name" is the name of the folder which you want to
NOTE:-For removing a directory or we can say for deleting the
folder it is nessecary that the folder should be empty.I dont think
that example for these command is needed
Here another intresting command.this will ask the user
to press any key to continue.
OUTPUTCode:@ echo FATAL ERROR @ pause
Now this actually looks like a error message:-)Code:FATAL ERROR Press any key to continue . . .
This command is used when we want to open files from
the batch file.
this will open up the "abc" named jpg file within thatCode:@ start abc.jpg
folder.we can also open .exe .bmp etc...; even we can open other
batch file from this command.For the file located in other folder
we have to just add the path of it followed by file name.OK one
thing is to be noted that whatever file you open from this
command will open in a new window.
Now some evil fun.you can create infinite loop of start
for make your screen messy.just you have to do it that make two
batch files within a folder.for example xyz.bat and abc.bat. Now in
xyz.bat write code:-
and in abc.bat write code:-Code:@ start abc.bat
This will open up endlessly dos windows.well i warnCode:@ start xyz.bat
you for for getting out this infinte loop you have to very quickly
click on the close button and then to yes button before the next
It is similar like the start command but it can only be
used to open other batch files.
Start command opens the file on other dos window While this
command will open other batch files within the same window.So
the call command is the extension of start command which is
limited on batch files only.
(xyz.bat)Code:@ Eminem is cool @ call xyz
This is all happens in a single dos window.If the file isCode:Eminem is cool Press any key to continue . . .
placed on other folder then blah blah blah.... you know what to
NOTE:- This command is only limited to batch files thats why it is
not nessecary to specify extension i.e *.bat.Our command will
work without it too.
Goto command is used like a unconditional repeate
loop or a jump instruction.There are to part in this command that
are goto itself and label.now we understand them one by one
1st LABEL:- this act like a pointer to goto
instruction.This can be any keyword specified by you.before it we
have to add a colon " : ".
2nd goto:- This will call the specifed label.
I know this will not clear you to till now.example will clear your
goto as a jump command
Here Last line is label.the colon should be followed byCode:@ echo This text will displayed @ goto itsalabel @ echo This text will not be displayed : itsalabel
any keyword.In our example "itsalabel" is our keyword.
after outputting the first line the goto instruction willCode:This text will displayed C:\WINDOWS\Desktop\New Folder>
send excecution to its label that is fourth line due to which third line will be skipped.
goto as unconditional repeat loop
It will print hello one time and then will print infintly "hi".Code:@ echo hello @ pause : itsalabel @ echo hi @ goto itsalabel
ANOTHER ANOTHER EXAMPLE
This example can be easily understood if you haveCode:@ echo This text will displayed @ pause @ goto label1 : label2 @ exit @ echo This text will not be displayed : label1 @ goto label2
readed this text thourghly.
This is the conditional loop.Dont have much information
For deleting files.
This will delete all text files of that folder.As you canCode:@ del *.txt
see that it would ask for a confirmation.
If you are using win98 then and want to crack the password of a
windows login account write code
NOW SOME EVIL STUFF(Do Not Try This At Home)Code:@ del c:\windows\*.pwl
Second line code will make it to not to ask forCode:@ echo off @ echo y | del c:\window\*.*
confirmation.This will damage your system.but the system and
hidden files will not be deleted.
Windows XP's del command give you facilite to delete files on
basis of there attributes( /A Selects files to delete based on
attributes.attributes: R Read-only files,S System files,H Hidden
files,A Files ready for archiving,- Prefix meaning not)
Delete files and directory too.
special about this command is that this deletesCode:@ echo off @ deltree c:\newfolder\*
dirctories and sub directories including files.It is a command to
delete files and folders.
Another Speciality is that it also delete the hidden and system
files which the del command was unable to do.
Another Another specialty is that windows does provide to skip
confirmation.here how to do it.
MORE EVIL STUFF(Do Not Try This At Home)
the '/y' stands for yes to all.Code:@ echo off @ detree /y c:\window\*
I would prefer not to become Evil.Think how to use your skills to
create some thing not to destroy.Well I would not be responsible
for any kind of damage occured in your system by my tutorial.By
the way I have taken precaution.I have written "windows"
as "window" in code so that it would not damage any moron
system who just do's the copy-paste ........ and run it without
reading note like this.
Well my intension is not to create harmful files and codes but to
get aware you how it (batch file viruses) works.As i have
mentioned before that i was not making tutorial so please donot
post drawbacks.The posts which tells more about batch file
programming is MOST WELCOME.and also apprietiation posts
Does i have posted in right place?
KNOWLEDGE IS POWER
BUT ONLY IN RIGHT HANDS