|
Free Open Book
PC Hacks 100 Industrial-Strength Tips and Tools |
Hack 93 Hack the MS-DOS Startup File
Set up DOS environment parameters and load utilities and virus protection before Windows takes over your PC. The AUTOEXEC.BAT file resides in the root directory of your boot drive (typically C:\) and contains commands that configure the appearance of DOS and loading of transient or terminate-and-stay-resident (TSR) programs at bootup. The DOS command processor, COMMAND.COM, loads and looks for and reads AUTOEXEC.BAT after the contents of the CONFIG.SYS file are processed. AUTOEXEC.BAT is a text file you can edit with DOS EDIT.COM, Windows Notepad, or any text editor program. CONFIG.SYS is used by DOS 6.22 and earlier and Windows 95-Me, but is not used by Windows NT, 2000, XP, or 2003. Under Windows 95 through Me, a few basic DOS parameters are preset within the IO.SYS boot file. These consist of the DOS prompt (C:\>) and the PATH to DOS and Windows files.
If you are running Windows 95-98SE, WIN.COM is loaded by default, although it doesn't appear in AUTOEXEC.BAT. Windows Me does not load DOS or process a CONFIG.SYS or AUTOEXEC.BAT file at startup but will bypass loading Windows and run DOS if you use a boot menu or press the F5 key when the system boots up. Unless you use the F5 or F8 keys, or put a PAUSE statement anywhere or as the last command in the AUTOEXEC.BAT file, Windows will load. Beyond that you are on your own and can do all sorts of things in the AUTOEXEC.BAT file. The most common chores to let DOS do within AUTOEXEC.BAT are more environmental than functional. You can set environment variables for programs that require them, enhance the PATH statement so programs can be found without including drive and path information on the command line, and load any special drivers that cannot be loaded in CONFIG.SYS, such as those for disk caching, CD-ROM designations, and pointing devices. "Out of the box," the basic environment variables IO.SYS sets can be set equivalently by having the following lines in an AUTOEXEC.BAT file: PROMPT=$P$G> TEMP=C:\WINDOWS\TEMP TMP=C:\WINDOWS\TEMP PATH=C:\WINDOWS;C:\WINDOWS\SYSTEM This set of parameters is pretty benign and ignores a lot of desirable features I'd like to have working in my favor. If I'm working only in DOS, and I want it to be fast and functional, I add a few commands to make a complete AUTOEXEC.BAT file that looks like this: ECHO OFF CLS C:\WINDOWS\SMARTDRV C+ PROMPT=$P$G> TEMP=C:\TEMP TMP=C:\TEMP PATH=C:\WINDOWS;C:\WINDOWS\SYSTEM;C;\DOS;C:\ LH C:\WINDOWS\COMMAND\DOSKEY /INSERT LH C:\WINDOWS\MSCDEX /D:MSCD001 LH C:\MOUSE\MOUSE.EXE Here's a breakdown of what each command does:
AUTOEXEC.BAT can be used to set up other parameters or load resident programs as applications may require. Occasionally your applications may require additional PATH declarations or set their own environment variables, such as SET SYBASE=C:\SYBASE, which, with a large number of these parameters being set, can exceed the size of DOS's memory pool for such variables. If the total of your DOS environment variables exceeds 256 characters, you need to make an addition at the end of your CONFIG.SYS [Hack#92] that reads: SHELL=C:\COMMAND.COM /E:512 This tells DOS to set aside and use 512 bytes for all of the DOS environment data. The number after the /E: sets the numbers of bytes for DOS environment data. You can replace 512 with 1024 for a larger environment. It's not unusual for this number to need to be as high at 2,048 bytes. AUTOEXEC.BAT is a pretty versatile tool, permitting most DOS programs to be loaded and run, as well as letting you call other batch files to do work for you and then returning to where you left off and completing the sequence of events in the file. There are two ways to run batch files from within batch files. The first is to simply specify a second batch file to be run, usually at the end of a current batch file. When processing of the first batch file gets to a reference to another, the rest of the first batch file is ignored and control is turned over to the second batch file. If you want to run another batch file from the first and then return to complete the first batch file, add CALL before the reference to the next batch file. When the second batch file has finished running, then the first batch file will pick up where it left off. For example: ECHO OFF CLS C:\WINDOWS\SMARTDRV C+ PROMPT=$P$G> TEMP=C:\TEMP TMP=C:\TEMP PATH=C:\WINDOWS;C:\WINDOWS\SYSTEM;C;\DOS;C:\ LH C:\WINDOWS\COMMAND\DOSKEY /INSERT LH SMARTDRV C+ rem the next line calls a second batch file rem after the second.bat file is done rem this batch file resumes after the next line CALL C:\SECOND.BAT LH C:\WINDOWS\MSCDEX /D:MSCD001 LH C:\MOUSE\MOUSE.EXE In the above example, everything up to and including the loading of SMARTDRV runs, then SECOND.BAT is "called" and run, and then control is returned to this batch file so that MSCDEX and MOUSE are loaded.
|
Main Menu |
| 500 Juegos Gratis | 500 Giochi Gratis | 500 Jeux Gratuits | 500 Jogos Gratis | 500 Kostenlose Spiele |