We seemed to have lost an art, writing batch files to do things for us...
What are they and what can they do to make some of your everyday
have been around for a long time, actually a Main Frame term from the early
So what are they and what can it do for you?
They are simply a file that is executable with a list of commands to
do a single task, a couple of tasks, or even a long list of tasks.
You can run it from the command prompt or if you are using DOS the
Do mundane, repetitive, and scheduled tasks every time with out taking time
away from other tasks.
Write a document to run automatically to do your backup and then schedule it to run when you
feel it needs to be done.
"Define, design, then assign".
Using it will lessen your work load and take the worry out of a task that has
to be done but you dread doing it.
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 happened 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
The 5 Steps to high quality and cheap
DIY Computer Repairs
Get It Today...
This is what a couple of them look like:
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
REM Install network redirector (load before dosx.exe)
REM Install DPMI support
As you can see there are a lot of abbreviations in the file, each one is
shortened because the original DOS
environment was very limited in
memory capacity - it was 640 KB 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 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.
It will do a lot of things for you once you have studied the
syntax (format) of the command.
You can have one 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 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
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 file?
Well lets have a look at a file that will open four programs -
path=C:\Program Files\Microsoft Office\Office10\
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 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 have .bat file extension in the code.
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 file worked your next step would be to schedule the start time
to execute the 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 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 it to open all the programs you use everyday at
startup instead of clicking on them one at a time, just make your 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.
Here is a sample
batch files I made to clean my temp directory:
Rem - This is a batch file to delete all the files from the temporary directory
Rem - Monte Russell 09/03/09
Rem - You are free to modify this file and distribute to all your friends!
Rem - http://www.diy-computer-repair.net
Rem select your drive
del /Q *.*
Rem this file will not delete files inside a folder if you want to add a folder this is how you do it
del /Q *.*
Automation is great...
Update 02/09/20 After using Win 10 for some time I have found that
using a batch file with this OS is sporadic, that is sometimes it will work as
advertised, sometimes it will fail, one of the failures comes when you try to
put the file in the "Startup" folder, it will not run. I have done some research
on why not and will do a article on this at a later date, or if you are stymied
at this time do a search on "Windows 10 startup folder".