• Complain

John Albert - Learn Batch File Programming!

Here you can read online John Albert - Learn Batch File Programming! full text of the book (entire story) in english for free. Download pdf and epub, get meaning, cover and reviews about this ebook. year: 2014, publisher: BookBaby, genre: Computer. Description of the work, (preface) as well as reviews are available. Best literature library LitArk.com created for fans of good reading and offers a wide selection of genres:

Romance novel Science fiction Adventure Detective Science History Home and family Prose Art Politics Computer Non-fiction Religion Business Children Humor

Choose a favorite category and find really read worthwhile books. Enjoy immersion in the world of imagination, feel the emotions of the characters or learn something new for yourself, make an fascinating discovery.

John Albert Learn Batch File Programming!
  • Book:
    Learn Batch File Programming!
  • Author:
  • Publisher:
    BookBaby
  • Genre:
  • Year:
    2014
  • Rating:
    5 / 5
  • Favourites:
    Add to favourites
  • Your mark:
    • 100
    • 1
    • 2
    • 3
    • 4
    • 5

Learn Batch File Programming!: summary, description and annotation

We offer to read an annotation, description, summary or preface (depends on what the author of the book "Learn Batch File Programming!" wrote himself). If you haven't found the necessary information about the book — write in the comments, we will try to find it.

Say you need to execute a set of commands over and over again to perform a routine task like Backing up Important Files, Deleting temporary files(.tmp,.bak, ~. etc) then it is very difficult to type the same set of commands over and over again. To perform a bulk set of same commands over and over again, Batch files are used. You can learn all this & lot more tricks in this book very easily!

John Albert: author's other books


Who wrote Learn Batch File Programming!? Find out the surname, the name of the author of the book and a list of all author's works by series.

Learn Batch File Programming! — read online for free the complete book (whole text) full work

Below is the text of the book, divided by pages. System saving the place of the last page read, allows you to conveniently read the book "Learn Batch File Programming!" online for free, without having to search again every time where you left off. Put a bookmark, and you can go to the page where you finished reading at any time.

Light

Font size:

Reset

Interval:

Bookmark:

Make

Learn Batch File Programming

By John Albert

Smashwords Edition

Copyright 2014 John Albert

SmashwordsEdition,LicenseNotes
This ebook is licensed for yourpersonal enjoyment only. This ebook may not be re-sold or givenaway to other people. If you would like to share this book withanother person, please purchase an additional copy for eachrecipient. If youre reading this book and did not purchase it, orit was not purchased for your use only, then please return toSmashwords.com or your favorite retailer and purchase your owncopy. Thank you for respecting the hard work of thisauthor.

B atch file programming is nothingbut the Windows version of Unix Shell Programming. Let's start byunderstanding what happens when we give a DOS command. DOS isbasically a file called command.com

It is this file (command.com) which handles all DOS commandsthat you give at the DOS prompt---such as COPY, DIR, DEL etc. Thesecommands are built in with the Command.com file. (Such commandswhich are built in are called internal commands.).DOS has somethingcalled external commands too such as FORMAT,

UNDELETE, BACKUP etc.

So whenever we give a DOS command either internal orexternal, command.com either straightaway executes the command(Internal Commands) or calls an external separate program whichexecutes the command for it and returns the result (ExternalCommands.)

So why do I need Batch File Programs? Say you need to executea set of commands over and over again to perform a routine tasklike Backing up Important Files,Deleting temporary files(*.tmp,.bak , ~.* etc)

then it is very difficult to type the same set of commandsover and over again. To perform a bulk set of same commands overand over again, Batch files are used. Batch Files are to DOS whatMacros are to Microsoft Office and are used to perform an automatedpredefined set of tasks over and over again.

So how do I create batch files? To start enjoying using Batchfiles, you need to learn to create Batch files. Batch files arebasically plain text files containing DOS commands. So the besteditor to write your commands in would be Notepad or the DOS Editor(EDIT) All you need to remember is that a batch file should havethe extension .BAT(dot bat)Executing a batch file is quite simpletoo. For example if you create a Batch file and save it with thefilename

batch.bat then all you need to execute the batch file is totype:

C:\windows>batch.bat

So what happens when you give a Batch file to the command.comto execute?

Whenever command.com comes across a batch file program, itgoes into batch mode. In the batch mode, it reads the commands fromthe batch file line by line. So basically what happens is,command.com opens the batch file and reads the first line, then itcloses the batch file. It then executes the command and againreopens the batch file and reads the next line from it. Batch filesare treated as Internal DOS commands.

*********************

Hacking Truth: While creating a batch file, one thing thatyou need to keep in mind is that the filename of the batch fileshould not use the same name as a DOS command. For example, if youcreate a batch file by the name dir.bat and then try to execute itat the prompt, nothing will happen.This is because when command.comcomes across a command, it first checks to see if it is an internalcommand. If it is not then command.com checks if it a .COM, .EXE or.BAT file with a matching filename.All external DOS commands useeither a .COM or a .EXE extension, DOS never bothers to check ifthe batch program exits.

*********************

Now let's move on to your first Batch file program. We willunlike always(Normally we begin with the obligatory Hello Worldprogram) first take up a simple batch file which executes orlaunches a .EXE program. Simply type the following in a blank textfile and save it with a .BAT extension.

C:

cd windows telnet

Now let's analyze the code, the first line tells command.comto go to the C:Next it tells it to change the current directory toWindows. The last line tells it to launch the telnet client. Youmay contradict saying that the full filename is telnet.exe. Yes youare right, but the .exe extension is automatically added bycommand.com. Normally we do not need to change the drive and thedirectory as the Windows directory is the default DOS folder. Soinstead the bath file could simply contain the below and wouldstill work.

telnet

Now let's execute this batch file and see what results itshows. Launch command.com (DOS) and execute the batch file bytyping:

C:\WINDOWS>batch_file_name

You would get the following result:

C:\WINDOWS>scandisk

And Scandisk is launched. So now the you know the basicfunctioning of Batch files, let' move on to Batch filecommands.

The REM Command

The most simple basic Batch file command is the REM or theRemark command. It is used extensively by programmers to insertcomments into their code to make it more readable andunderstandable. This command ignores anything there is on thatline. Anything on the line after REM is not even displayed on thescreen during execution. It is normally not used in small easy tounderstand batch programs but is very useful in huge snippets ofcode with geek stuff loaded into it. So if we

add Remarks to out first batch file, it willbecome:

REM This batch file is my first batch program which launchesthe fav hacking

tool; Telnet

telnet

The only thing to keep in mind while using Remarks is to notgo overboard and putting in too many of them into a single programas they tend to slow down the execution time of the batchcommands.

ECHO: The Batch Printing Tool

The ECHO command is used for what the Print command is inother programming languages: To Display something on the screen. Itcan be

used to tell the user what the bath file is currently doing.It is true that Batch programs display all commands it is executingbut sometimes they are not enough and it is better to also insertECHO commands which give a better description of what is presentlybeing done. Say for example the following batch program which isfull of the ECHO command deletes all files in the c:\windows\tempdirectory:

ECHO This Batch File deletes all unwanted Temporary filesfrom your system ECHO Now we go to the Windows\tempdirectory.

cd windows\temp

ECHO Deleting unwanted temporary files....

del *.tmp

ECHO Your System is Now Clean

Now let's see what happens when we execute the above snippetof batch code.

C:\WINDOWS>batch_file_name

C:\WINDOWS>ECHO This Batch File deletes all unwantedTemporary files from your

system

C:\WINDOWS>ECHO Now we go to the Windows\temp directory.Now we go to the Windows\temp directory.

C:\WINDOWS>cd windows\temp Invalid directory

C:\WINDOWS>ECHO Deleting unwanted temporary files Deletingunwanted temporary files...

C:\WINDOWS>del *.tmp

C:\WINDOWS>ECHO Your System is Now Clean Your System isNow Clean

The above is a big mess! The problem is that DOS isdisplaying the executed command and also the statement within theECHO command. To prevent DOS from displaying the command beingexecuted, simply precede the batch file with the

following command at the beginning of the file:

ECHO OFF

Once we add the above line to our Temporary files deletingBatch program , the output becomes:

C:\WINDOWS>ECHO OFF

This Batch File deletes all unwanted Temporary files fromyour system Now we go to the Windows\temp directory.

Invalid directory

Deleting unwanted temporary files...

File not found

Your System is Now Clean

Hey pretty good! But it still shows the initial ECHO OFFcommand. You can prevent a particular command from being shown butstill be executed by preceding the command with a @ sign. So tohide even the ECHO OFF command, simple replace the

Next page
Light

Font size:

Reset

Interval:

Bookmark:

Make

Similar books «Learn Batch File Programming!»

Look at similar books to Learn Batch File Programming!. We have selected literature similar in name and meaning in the hope of providing readers with more options to find new, interesting, not yet read works.


Reviews about «Learn Batch File Programming!»

Discussion, reviews of the book Learn Batch File Programming! and just readers' own opinions. Leave your comments, write what you think about the work, its meaning or the main characters. Specify what exactly you liked and what you didn't like, and why you think so.