Batch Files
Printer Friendly Page

- - Back Home - -


Site Directory

Ansi
Ascii/ISO Codes
Beep Codes
Bootdisk Info
Old Boots Info
Colors Chart
Dos Interlink
Dos Overview
Download Section
Fun Photos
Grain Elevator
GUI's
History
Items for Sale
Links
PCXT Photos
Quotes
°C/°R/°K/°F Charts
TRS80 Stuff
UTC Time
GuestBook

Credits

Valid CSS!





In this section,we will show how to assemble a simple batch  (.bat)  file. You could also consider editing the path statement in your  autoexec.bat  file to show the directory where the *.exe or *.com file resides that you are making the *.bat file for.  In the following example, replace the data in the [ ], with the correct name, drive, directory, filename, etc.

At the DOS prompt, ( do NOT include the "[ ]" ),  type:

Congratulations, you have just made your first batch file.  You can always edit the *.bat file using a text editor, such as Windows? Notepad.  If the need arises, you can edit the  autoexec.bat and the config.sys  files, using a text editor, also. For the Windows user, refer to the  last  paragraph on this page.



For The Windows Users


The stuff you need to know before you can write batch programs.



Where to find the missing commands: If you have access to a Windows 95 CDROM, you can find almost everything in the \Other\Oldmsdos directory. If you're like me, you'll copy every bit of it into your \Windows\Command directory. If you don't have access to your CDROM, check out Microsoft's web site. The actual files (1.47 megabytes compressed) can be found at: ftp://ftp.microsoft.com/products/Windows/Windows95/CDRomExtras/OtherUtilities/olddos.exe (or) ftp://ftp.microsoft.com/softlib/mslfiles/olddos.exe .

Other useful DOS commands are winset.exe and shortcut.exe. Winset lets you set environment variables globally (they persist once your batch file ends). Shortcut lets you make and modify shortcuts from the command line. You'll find both of these together as "envars.exe" on your CDROM under \Admin\Apptools\Envvars (or) from Microsoft at: ftp://ftp.microsoft.com/products/Windows/Windows95/CDRomExtras/AdministrationTools/
ApplicationTools/envars.exe .

You may also download the   envars.exe 44 KB  and  olddos.exe 837 KB,  locally.

Where to get help on DOS commands: You should already know about the /? option that every DOS command responds to. If you have Windows 95 you may wonder why you can't find DOS command help by using the Help icon on the Start menu. I wonder. But if you get the missing "OldDos" commands (see the item above), you'll get the HELP command. Actually, you don't need the HELP.COM file. All it does is run QBASIC with the undocumented /QHELP option (uppercase) which opens up the HELP.HLP data file. Yes, you get QBASIC.EXE and HELP.HLP with the OldDos stuff. You'll also find useful info (even if you thought you knew it all) by reading the text files in your Windows directory. If you installed Windows in your C:\Windows directory, You can find the following files: Config.txt, Msdosdrv.txt, Programs.txt , and Tips.txt, by entering them (one at a time) at the Start | Run command line. I've been told that on German computers, the spelling of some of the file names is slightly different (For example "programm.txt" instead of "programs.txt"), so look around if you don't have an English installation of Windows!

How do I write batch programs ... You'd be surprised how many people are in that narrow transition period of knowing how to type commands, but not knowing how to put them together in a batch file. Here is the short version: Get yourself a DOS prompt (Start | Run) . Type in the commands you need to do whatever it is you need to do. If your commands work, open up Notepad and type those SAME COMMANDS in the SAME ORDER. Don't type what appeared on the screen, just type what you actually typed in. Save that file with a bat extension ( For example "test.bat"). Now instead of having to type the commands, you can just double-click the batch file. Sure, your first batch file may only have two or three commands, but it counts. It's a batch program.


The following are examples of my autoexec.bat  and config.sys files.  All statements in these two files are  single spaced .  In the autoexec.bat file, notice the  prompt  command line.  It utilizes the
Ansi escape codes and will produce:   C:\ ...   at the DOS prompt.

In both the autoexec.bat and the config.sys files, notice the  REM  and  rem  lines  (rem may be in either
lower case or upper case fonts).  This command  "remarks"  out the command line that it is in front of, so that the device or application will not load at boot up.  REM is very helpful in troubleshooting and
finding devices and applications that may not be working or loading properly at boot up.