PC Hacks 100 Industrial-Strength Tips and Tools Free Open Book

PC Hacks 100 Industrial-Strength Tips and Tools

Previous Section  < Day Day Up >  Next Section

Hack 93 Hack the MS-DOS Startup File

figs/beginner.gif figs/hack93.gif

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.

You can bypass CONFIG.SYSand AUTOEXEC.BAT files if BootKeys=1 is configured in MSDOS.SYS [Hack #91]. To use this feature, press the F5 key when you see the "Starting MS-DOS..." or "Starting Windows.." notice at startup.

You can also "walk through" and accept or reject individual CONFIG.SYS and AUTOEXEC.BAT commands by pressing the F8 key instead of F5.


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:


ECHO OFF

Keeps every subsequent command from echoing its invocation and output to the screen. It makes things neater, but you can omit it if you want to see the BATch file run to be sure everything looks OK.


CLS

This means "clear screen" and gives a clean palette to view as AUTOEXEC.BAT runs.


C:\WINDOWS\SMARTDRV C+

Starts the SMARTDRV disk caching program providing delay-write/write-cached performance enhancements to drive C:. Add D+, E+, etc. for additional hard drives. The DOS copy of SMARTDRV is replaced by Windows's VCACHE driver after Windows loads.


PROMPT=$P$G>

Ensures the DOS prompt shows the current drive and folder.


TEMP=C:\TEMP

You have to create the C:\TEMP folder (with MD TEMP at the C:\> prompt) to use this, but it keeps the temporary files from cluttering the C:\WINDOWS directory structure.


TMP=C:\TEMP

Same as above. TMP is declared for compatibility with older DOS and Windows programs.


PATH=C:\WINDOWS;C:\WINDOWS\SYSTEM;C:\WINDOWS\COMMAND;C:\

Adds the DOS folder and root directory so commands entered at the DOS prompt can find their required programs. Feel free to add C:\DOS in the path if you have such a folder and some fond memories of it, or specific DOS programs you want to be able to access readily.


LH C:\WINDOWS\COMMAND\DOSKEY /INSERT

Once you've experienced the ability to use the up and down arrow keys to recall previously entered commands at the DOS prompt, you'll never go back. DOSKEY remembers a series of command-line entries and can play them back by scrolling through them using the up arrow key. The /INSERT parameter allows you to edit the current and previous command-line entries without erasing what was there. DOSKEY features remain intact and available under Windows.


LH C:\WINDOWS\MSCDEX /D:MSCD001

MSCDEX is DOS's way of assigning a logical drive letter to a CD-ROM drive. Although Windows provides its own version of MSCDEX and makes this line inactive, you will need it for DOS. LH is an abbreviation for LOADHIGH, which places the program in upper memory. MSCDEX functions are required for Windows 95 but are displaced by Windows drivers when 98 or Me load and run.


LH C:\MOUSE\MOUSE.EXE

This is an example of loading a mouse driver into high memory. DOS's mouse driver or a mouse driver supplied with a pointing device is used for DOS but ignored in Windows, which provides its own driver.

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.

    Previous Section  < Day Day Up >  Next Section
    Index: [SYMBOL][A][B][C][D][E][F][G][H][I][J][L][M][N][O][P][Q][R][S][T][U][V][W][X][Z]


         Main Menu
    PC Hacks
    Table of Contents
    Copyright
    Credits
    Preface
    Chapter 1. Basic System Board Hacks
    Chapter 2. Basic System Board Setup
    Chapter 3. CPU Hacks
    Chapter 4. Memory Hacks
    Chapter 5. Disk Hacks
    Chapter 6. Disk Drive Performance Hacks
    Chapter 7. Video Hacks
    Chapter 8. I/O Device Hacks
    Chapter 9. Boot-Up Hacks
    Introduction: Hacks #85-94
    Hack 85 Make a Bare Disk Bootable
    Hack 86 Configure a Multiboot System
    Hack 87 Multiboot with Third-Party Utilities
    Hack 88 Speed up Operating System Installation and Maintenance
    Hack 89 Access NTFS Files from Other Operating Systems
    Hack 90 Give Your XP Installation Access to the Recovery Console
    Hack 91 Hack the Windows 95/98/Me DOS Startup
    Hack 92 Hack the MS-DOS Configuration File
    Hack 93 Hack the MS-DOS Startup File
    Hack 94 Hack the Windows NT/2000/XP Boot Loader
    Chapter 10. Configuring a New PC
    Colophon
    Index


    More Books
    PHP Hacks
    Processing Xml With Java - A Guide To Sax, Dom, Jdom, Jaxp, And Trax
    The Koran (Holy Qur'an)
    Macromedia Flash 8 Bible
    Search Engine Optimization for Dummies
    YouTube Traffic
    PHP 5 for Dummies
    Harry Potter and The Chamber of Secrets
    Harry Potter and the Sorcerer's Stone
    The Pilgrim's Progress
    Wireless Hacks
    Flash Hacks. 100 Industrial-Strength Tips & Tools
    PayPal Hacks. 100 Industrial-Strength Tips and Tools
    Amazon Hacks
    Pdf Hacks
    The Da Vinci Code
    Google Hacks
    The Holy Bible
    Windows XP For Dummies
    Harry Potter and the Half-Blood Prince
    Seo Book
    Upgrading and Repairing Networks
    Macromedia Dreamweaver 8 UNLEASHED
    Windows XP Annoyances
    Windows XP Hacks
    Microsoft Windows XP Power Toolkit
    Teach Yourself MS Office In 24Hours
    iPod & iTunes Missing Manual
    PC Hacks 100 Industrial-Strength Tips and Tools
    PC Overclocking, Optimization, and Tuning - 2th Edition
    PC Hardware In A Nutshell 3rd Edition
    PC Hardware in a Nutshell, 2nd Edition
    Upgrading and Repairing PCs
    Google for Dummies
    MySQL Cookbook
    Teach Yourself Macromedia Flash 8 In 24 Hours
    PHP CookBook
    Sams Teach Yourself JavaScript in 24 Hours
    PHP5 Manual
    Free Games Paper Airplanes
    500 Juegos Gratis 500 Giochi Gratis 500 Jeux Gratuits 500 Jogos Gratis 500 Kostenlose Spiele