DOS Batch Files
I actually learned this "programming language" after I had learned BASIC and C. Anyway, sense you are here I figure that you might be new to this whole programming thing. So let me give you a very quick run down of this whole deal. First, if you have never seen programming language, it looks something like this:
@echo off
echo Hello World!
That program is one of the most famous. It is called the "Hello World" program and was the first program written. I guess you can say that it is kind of a custom to make that the first program that you write when you learn a new language. That language was DOS batch file and in each category you will find the hello world program written for you in the language of that category. So, without further ado, lets get coding.
FIRST - You need what is known as an editor. Now, for .bat (extension for Batch files) you can use notepad. Just what can .bat files do you ask? Well, lets say for example you, like me, use AOL IM, MSN Messenger, and Outlook Express. Even better is that you use all of them at the same time. You may have wished that you could just click one icon and all of the sudden all those programs would spring to life and work for you, well, with a .bat file you can do just that. With just a double click on a single icon, you can launch MSN, AOL IM and Outlook at the same time. Batch files allow the user to define what programs or task are to be done when the .bat file is ran. A .bat file is like a set of instructions for your computer to follow. You can run just about any program that you want using a .bat file. Most people create them to run their most used programs all at once. Windows now a days kinda creates its own batch files and gives you ways to edit them. All those little icons in your system tray, well, a batch file told them to run. So, how do I create a .bat file you ask? Well, lets take a look.
SECOND - OK, so you want to create a .bat file and you know witch programs you want to run all at once. Now, before you go link happy and link up all your windows programs to spring in to action all at once let me warn you. Doing a LOT of programs all at once can drive your computer up a wall and not to mention crash it. Yeah, that would suck wouldn't it. As I said before, .bat files are only for linking a few files at a time. Lets take a look at that .bat file I was talking about earlier. This particular .bat file opens up AOL IM and MSN on my PC.
@echo off
CD Progra~1
CD aim95
aim.exe
msmsgs.exe
OK, lets break down the program shall we. The "@echo off" part has to be there. Don't ask me why or anything else like that because I don't know why. Now the "CD Progra~1" part, well, you see you need to go into DOS and type in "DIR/P". What that will do is bring up a list of how the computer views all your programs and folders in that current directory. When you bring up DOS it may show "C:\Windows>" or something like this:
C:\> ((Type "CD.." to get it to look like this))
now type in:
C:\> DIR
This, or something similar, comes up:
Directory of C:\
Progra~1 <DIR> 1999/02/23 2:00 am
See that part in yellow? That is what we are interested in. I know for a fact that AOL IM and MSN are located somewhere in that folder. I know that it is a folder because it has "<DIR>" after its name. If you are not sure exactly where your program is located, use the Windows "Search" feature (Start -> Search -> For files or folders) to find exactly where it is. Then go into DOS and locate the file. Now, what the "CD Program~1" does is tells the computer to look in the "Programs Directory." The same thing for "CD aim95", it tells the computer to look in the "AIM95 Directory." Last but not least, the aim95.exe and msmsgs.exe commands tell the computer to run the programs. So, in review, the computer must first find the folder or "Directory" in which the programs are stored and then it can run those files.
THIRD - Now, this is really really important, when you are writing your .bat file in notepad you must type in the name of the folder EXACTLY the way it looks on your DOS SCREEN, NOT WINDOWS EXPLORER. The reason your folders have those weird names like "Progra~1" is because your computer is in a way conserving space by omitting to show the entire folder's name. That is just the way DOS works and sense you are writing a DOS program, you need to make sure that you type it in that way to.
FOURTH - Now, once you have your file written in notepad and you are all ready to save it, you must save it a certain way. Go to "file" and click "Save As", then when you type in the name, lets say for example "Test" make sure you type it with the .bat extension so it would look like "Test.bat". That way your computer knows to open the file and run it. Now you can go back later and edit the file in notepad or any other text editor and then all you have to do is hit save.
FIFTH - Run it! Go find where you saved the file and double click on it. You should see the programs spring to life without you doing anything but double clicking the file. So now here comes the good part, lets put it on your desktop so you don't have to search for it each and every time. Right click on the file, then choose "Send to" and then click "Desktop." That will send a shortcut to your desktop. Now an icon is picked for you, but you can change that. Go find the icon, it should be on your desktop and have to title "Test" or whatever you saved your file as. Then right click on it, click "Properties", then find where it says "Change Icon" towards the bottom right. You may have to click through the tabs at the top, but it's there somewhere. Click it and then choose your icon, and click OK and OK again. That's it, you should now see your Icon sitting where the old one was. If you want to change the name, right click on the Icon and hit "Rename", then name the Icon anything you want. Mine is called "Launch Comm. Programs" and has a Satellite for its Icon.
That's it! You have written your first program. Now amaze all your friends with a simple, quick, and neat way to open multiple programs all at once. Don't be discouraged though if your program doesn't work right off the bat. It may take some tweaking before it works just right, but keep at it. Keep checking back here for some more programs and ideas as I build up the page. Until then, happy coding!
LINKS
(Coming Soon)
IDEAS
Create the "Hello World" program.
Create a .bat file to open two or more of your favorite programs.
|
||