|
|||||||
Batch FilesDIY-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 -
and Autoexec.nt
As you can see there are a lot of abbreviations in the file, each one is conotated (shortened) because the original DOS
A short list of explanation for the abbreviations in the sample above:
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
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...
![]() Return to previous page
Return to top
From the Desert South West ~ Arizona, USA |
|||||||
|
|||||||
|
|
|||||||