Documente Academic
Documente Profesional
Documente Cultură
//
// by Iconious
//
// http://www.oldskoolphreak.com
June 28, 2003
What is a batch file?
Batch files are a list of command line instructions that are
"batched" together in one file. Most of the command lines can be
executed within the command prompt, but batch files make the work
load much easier. Batch files can be opened, copied, and edited
using notepad. They are used for simple routines and low-level
machine instruction. On Windows, many batch files can be seen
within the c:\Windows directory. Batch files, more or less, make
up the backbone of the Windows Operating System. The operating
system must have access to these files and be able to add and
delete instructions from them. Delete them, and you have
effectively disabled the OS. I think I read some where that batch
files are one of the most primitive forms of virii. (Please
correct me if I'm wrong.) I'll explain later in this tutorial how
using batch files can be used as virii.
Example of a batch file:
---------------------------------------------------------------
cls
REM *******************************************
REM ** Cookie Delete Program **
REM *******************************************
deltree /y c:\windows\cookies\*.*
deltree /y c:\windows\tempor~1\*.*
pause
cls
REM Cookies deleted!
:end
---------------------------------------------------------------
If you didn't guess by the title of the batch file, that paticular
batch file deletes Window's cookies and temp files simply by
double clicking on the file itself. I found that very useful file
on a website when I first began batch programming. Let's break
this file down.
cls - Clears any previous data on the command prompt
REM - or "Remark" - Lines beginning with REM do not contain
commands but instructions or messages that are displayed for the
user. The command REM was used here to show a title (Cookie Delete
Program).
deltree - deltree can be used to delete files or even directories
or sub-directories. In this case, the cookies and temp directories
were deleted (these directories are rebuilt automatcally),
including the files inside.
/y - This parameter was passed to deltree, telling it to answer
"Yes" to any confirmation questions without interuppting the
process.
pause - The pause command stops the process temporarily, listing
the user all the files being deleted in the process. It also
prompts the user with a message "Press any key to continue" Once
a key is pressed, the process continues.
cls - Clears the screen once again.
REM - Prompts the user with the message, "Cookies Deleted!"
:end - Ends the process created by the batch file
*Note the above process was created to show the user
the entire process. If you do not want the user to see the entire
process, add @ECHO OFF below the first cls.*
Feel free to copy the above batch file into notepad for self use,
remember to add the extension ".bat" (Without quotation marks) at
the end of the file name.