Batch Files

DIY-Computer-Repair can help!


Batch files have been around for a long time, actually a Main Frame term from the early 1960's.

So what is a batch file and what can it do for you?

A batch file is simply a file that is executable with a list of commands to do a task, a couple of tasks, or even a list of tasks.

The batch file runs from the command prompt or if you are using DOS the command line.

Some examples of a batch file -

If you start a Command Prompt while in Windows you will use a batch file called Autoexec.nt - note the .bat is a dos term that stands for batch, like .com stand for command, .sys stands for system and so on.

If you do a search on your computer you for Autoexec.bat you will not find it unless you happed to copy it from a DOS environment. On a Windows NT and forward Operating Systems it is called Autoexec.nt. This is to keep the file from being executed by mistake. It can only be called (or executed) by the Command Prompt. Although you can run Autoexec.bat in the Command Prompt it is not a good idea because the file can set environment variables that could cause your computer to hang or even crash.

This is what a couple of batch files look like:

Autoexec.bat -

@echo off
CLS
path=a:\
ver

and

Autoexec.nt

@echo off

REM AUTOEXEC.BAT is not used to initialize the MS-DOS environment.
REM AUTOEXEC.NT is used to initialize the MS-DOS environment unless a
REM different startup file is specified in an application's PIF.

REM Install CD ROM extensions
lh %SystemRoot%\system32\mscdexnt.exe

REM Install network redirector (load before dosx.exe)
lh %SystemRoot%\system32\redir

REM Install DPMI support
lh %SystemRoot%\system32\dosx

As you can see there are a lot of abbreviations in the file, each one is conotated (shortened) because the original DOS

Fix It! Your
DIY Computer Repair Newsletter!
Click here to get your copy of Fix It!

environment was very limited in memory capacity - it was 640 K maximum in size, most text files now days are bigger than that!

A short list of explanation for the abbreviations in the sample above:

@echo off - turns off the repeat of the command when it is executed by the batch file.

REM - Remark - non executable text

lh - load high - load the program in to high memory before executing the command.

PIF - Program Information File - this file has parameters and configuration information for the Windows Operating System.

There are a lot more of these abbreviations.

So a batch file will do a lot of things for you once you have studied the syntax (format) of the command.

You can have a batch file run your backup every day at a certain time.

Or you could have a batch file open different programs at a given time of day, say you have a meeting every Tuesday at 10:00 AM. for the meeting you will need Power Point, Excel, Word, and your Netmeeting. Instead trying to remember the time and to open the programs you could write a batch file then schedule it to run every Tuesday at 10:00 AM. Then the next Tuesday at 10:00 AM your programs will open automatically. A boon for us forgetful types.

When your virus scan runs every day at 9;00 AM it is done by a type of batch file, not the command prompt type but a schedule that has the program name, location, and time of execution.

So how would you setup the batch file?

Well lets have a look at a file that will open four programs -

four-programs-start-10-am.cmd

path=C:\Program Files\Microsoft Office\Office10\

start POWERPNT.EXE
start EXCEL.EXE
start WINWORD.EXE

path=C:\Program Files\NetMeeting\
start conf.exe

Note: Netmeeting has to be setup before it will work as in this example, you can set it up by typing netmeeting in the run box from the start button.

Now you have your batch file, note that I named it .cmd, this is the same as .bat, it is a change that Microsoft introduced with Windows NT because the first version of the Operating System did not .bat file extension in the code.

You will find more information on writing and configuring batch files in the Self Computer Repair Unleashed! E-Book.

So the next step would be to test the file by running it from the command prompt or the run box with the start button.

How did you do? Messed it up? Well if you copied the lines of commands from this web page and put it in a word document you copied all the code in the web page that makes if pretty - the formatting code. Try it again and paste it in to Notepad.exe then save it with a name and the .cmd extension, put it on your desktop so you can find it easily.

Now what happened? All four of the programs started?

If your batch file worked your next step would be to schedule the start time to execute the batch file. You could use the 'AT' command in the batch file but it is easier to run the Windows Task Scheduler from the Control Panel.

The Task Scheduler is fairly easy to configure the only thing you will have to remember is where you placed your batch file after you tested it.

There are a lot of things you can use a batch file for running a set of programs at a given time is just one.

You could use a batch file to open all the programs you use everyday at startup instead of clicking on them one at a time, just make your batch file then place it in the startup folder in your profile under the Documents and Settings folder, or you could schedule it...

In one of my e-courses I setup a way to delay the start of services, using a batch file you could have your everyday programs open one at a time on a schedule. The only draw back to using the schedule is that if you are late in starting your computer the scheduled task time will have passed and the program will not run, in that case you would have to open it manually.

Automation is great...



Are you a member?
Does your Computer need some TLC?
More information about Batch Files in the
DIY Membership Section!


Hard Drives, Internal or External, All available at Newegg.com


Q and A

This site contains a lot of information. As with any publication not all information is available due to space, time, or subject constraints.

If you have a question that you did not find the answer on this web site  you a can ask your question here and we will endeavor to get you the most up to date answer possible!

Free Stuff!


Thank you for visiting my web site, and please come back again.

© www.diy-computer-repair.com '2008 Copyright Russell Enterprises All Rights Reserved
DiY Computer Repair contact support and sig. If you find this Web Site useful, feel free to recommend it to a friend.



Return to previous page



 
This website is not intended for children under the age of 18

Home
   Support   About owner   Site Map
Why I use SBI  Privacy Policy   Disclaimer


 

 



Return to top

From the Desert South West ~ Arizona, USA
Copyright DIY-Computer-Repair.Com 2009

powered-by-sbi



My Twitter! xml-rss Add to My Yahoo!
Add to My MSN Add to Google AddThis Social Bookmark Button My StumbleUpon Page Computer Blogs - BlogCatalog Blog Directory

Page copy protected against web site content infringement by Copyscape

 www.diy-computer-repair.com BBB Business Review

 
 One repair will pay for three copies of this book!
More for you! Think of the possibilities!
Now you can know what I know!

Today!


Index
Home Page

Information Index
Audio devices
Affinity? What is it?
Can't find the Any Key
Batch Files?
BIOS. What is it? What does it do?
Cases
CPU's or Processors
Glossary of terms
Glossary of terms Page 2
Keyboard and your Mouse
Mini Computers
Motherboard
Memory
Modems
Networking
Networks Page 2
Networking - Wired or Wireless
Networking - Firewalls
Networking - Connectivity
Networking - Signal strength
Paging file or Memory dump file?
Solar Power for Backup when the power is out?
Power supplies
Power supplies Page 2
Storage
USB
Video
Virtual Drives
Virus
VPN - Virtual Personal Network

Senior Citizen?
Build yourself a computer


Opinion
Are We Doomed?