Batch Files - The Basics

  • UserId: 1
  • Title: Batch Files - The Basics
  • Url: the-basics
  • Summary: Batch Files - The Basics
  • Search:
  • DateCreated:
  • DateModified:
  • Published: 1
  • Pageable: 1

Introduction: Welcome to the world of scripting Windows Batch Files!

This world is vast... very vast. It would take a book with many chapters and 100's, if not 1000's of pages, to cover the whole of this world. So, I'm just focusing on 3 tasks that can be carried out using batch files:

Defragmentation Backing up Mapping network drives Now a little explanation about each:

Defragmentation: Microsoft Windows XP, 2003 and 2000 use a cut-down version of Executive Software's defragger. It basically takes all your files on your hard-drive and sorts them into order, in a similar way to how you would sort a pile of DVDs into alphabetical order (yes, I'm that geeky).

Backing up: Backing up refers to creating backups (copies) of your data, which would be used in the event of a system failure, or data loss. This can range from simply saving your spreadsheet to a floppy disc as well as your hard-drive, to huge removable hard-discs or tape drives periodically copying your data.

Mapping network drives: Not many of you will probably need this, but it's something I find very useful, particularly when using a laptop with various user logins on several different networks - each with a fileserver of some sort. It is a process that basically tricks your computer into thinking a hard-drive on another computer (on the same network) is actually part of the system.

Command line: Command line is basically a line of text, that when inputted into a command prompt, it instructs the computer to carry out a specific task, or series of tasks.

There are 100's, if not 1000's of different commands that Windows understands. But I'll only be referring to a handful within these articles.

I created a list of commands and uploaded it here is you'd like more information.

Commands: The commands we'll be using include the xcopy function, the defrag program, and net use for mapping drives. Along with echo.

Opening a command prompt window: Click on Start > All Programs/Programs > Accessories > Command Prompt Or, alternatively Click on Start > Run (Windows Key then R) and type in cmd

Entering a command: Now that you have a command prompt window open, you can begin entering your commands. Choose wisely - as some have negative effects! I'd start with typing ipconfig and pressing enter. It'll show you your IP address amongst other things.

Creating a batch file: In the following 3 articles, you'll be given .txt examples - these wont work as batch files, you'll need to re-save them. Open them in notepad, click on File > Save as, then choose 'All Files' from the drop-down box, and re-name the file with the .bat extension instead of .txt - et voila! You've created a batch file. You'll notice the icon has changed to a MS-DOS style too.

Now that you can use the command prompt, you can begin reading through the 3 articles.

Categories that this Post has been filed under

Tags that this Post has been tagged with

Comments

[...] Before you delve into the world of Windows Batch Files, take a look at the basics. [...]


[...] Before you delve into the world of Windows Batch Files, take a look at the basics. [...]


[...] Before you delve into the world of Windows Batch Files, take a look at the basics. [...]


Add a Comment