AUTOEXEC.BAT
From Wikipedia, the free encyclopedia
AUTOEXEC.BAT is the name of a system file found originally on the MS-DOS operating system. It is a plain-text batch file that is located in the root directory of the boot device. The name of the file is a portmanteau of the words "automatic" and "execution", which describes its function in automatically executing commands on system startup; the portmanteau was coined in response to the 8.3 filename limitations of the FAT file system family.
Contents |
[edit] Usage
The AUTOEXEC.BAT file is found only on DOS-based systems. Because Windows 3.x, Windows 95, and Windows 98 all ran on top of DOS the file was retained but was not strictly required to run Windows programs. Windows Me did not parse the AUTOEXEC.BAT file during the Windows boot process[1], instead applying default settings through the registry. An unofficial workaround exists [2].
The file is executed once the operating system has booted and after the CONFIG.SYS file has been processed. On Windows, this occurs before the graphical environment has been started. Unlike CONFIG.SYS, the commands in AUTOEXEC.BAT can be entered into a DOS prompt. They are just standard commands that the computer operator wants to be executed automatically whenever the computer is started, and can include batch files.
AUTOEXEC.BAT is most often used to set environment variables such as keyboard, soundcard, printer, and temporary file locations. It is also used to initiate low level system utilities, such as the following:
- virus scanners
- Disk caching software - SMARTDRV.EXE from Microsoft the most common
- Mouse drivers
- Keyboard drivers
- CD drivers
- Miscellaneous other drivers
[edit] Examples
In early versions of MS-DOS, AUTOEXEC.BAT was by default extremely simple.
@ECHO OFF PROMPT $p$g
All this does is suspend automatic screen output of all input character sequences, and set the DOS prompt to "C:\>" instead of simply "C>".
Later versions were often much expanded with numerous third party device drivers. The following is a basic DOS 5.x type AUTOEXEC.BAT configuration, consisting only of essential commands:
@ECHO OFF PROMPT $P$G PATH=C:\DOS;C:\WINDOWS SET TEMP=C:\TEMP SET BLASTER=A220 I7 D1 T2 LH SMARTDRV.EXE LH DOSKEY LH MOUSE.COM /Y WIN
This configuration sets common environment variables, loads the disk cache SMARTDRIVE on line six, places common directories into the default path, and initializes the DOS mouse / keyboard drivers, before starting Windows.
In general .sys files were called in config.sys, and .exe programs such as the popular disk caching software SMARTDRIVE provided by Microsoft with DOS 5x, were loaded in the autoexec.bat file. Some devices such as mice, could be loaded either as a .sys file in config.sys, or as a .com in autoexec.bat [3], depending upon the manufacturer.
Lines prefixed with the string "REM" are remarks and are not run as part of AUTOEXEC.BAT. The "REM" lines are used for comments or to temporarily disable drivers (e.g. for a CD-ROM). An alternative, though less common, method for commenting is using double colons (::).
[edit] Issues
One of the problems with the versions of Windows that ran on top of DOS, was a lack of conventional memory. This was due to the archaic design of the original x86 processor, which was originally only able to address 1024 K, or an effective 640 K of memory. While this was later extended with new processor modes, DOS was not able to load low level autoexec.bat type drivers into extended memory.
Users were therefore presented with the baffling situation, of potentially having 8196K of physical memory, but were not able to run software that required a mere 512K of memory, because the DOS drivers in the autoexec.bat file, especially CD-ROM and disk compression drivers, had taken up too much conventional memory.
Users were left to experiment with ‘Load High (LH)’ commands, based upon the emm386 memory manager loaded in the config.sys files, in order to try and move drivers from the 640K region, into the 640-1024K range, via memory maps. Lack of conventional memory proved to be a particular issue for gamers, and generated numerous baffled calls to support desks. Many gamers were forced to maintain several boot disks, each with game specific PC configurations.
Resolving driver and conventional memory issues, has been cited as a key reason for adoption of the Windows based Direct-X gaming interface[4], which could access the entire physical memory of the PC, and relied upon Windows drivers to access hardware.
[edit] Dual Booting DOS and Win 9.x
When installing Windows 95 over a preexisting DOS/WINDOWS install, CONFIG.SYS and AUTOEXEC.BAT are renamed to CONFIG.DOS and AUTOEXEC.DOS. This is intended to ease dual booting between Windows 9.x and DOS. When booting into DOS, they are temporarily renamed CONFIG.SYS and AUTOEXEC.BAT. Backups of the Win95 versions are made as .W40 files.
[edit] OS/2 / NT
On Windows NT and its derivatives, Windows 2000, Windows Server 2003 and Windows XP, the equivalent file is called AUTOEXEC.NT and is located in the %SystemRoot%\system32
directory. The file is not used during the operating system boot process; it is executed when the MS-DOS environment is started, which occurs when an MS-DOS application is loaded.
The AUTOEXEC.BAT file may often be found on Windows NT, in the root directory of the boot drive. Windows only considers the "SET" and "PATH" statements which it contains, in order to define environment variables global to all users. Setting environment variables through this file may be interesting if for example MS-DOS is also booted from this drive (this requires that the drive be FAT) or to keep the variables across a reinstall. This is an exotic usage today so this file usually remains empty. The TweakUI applet from the PowerToys collection allows to control this feature (Parse Autoexec.bat at logon).
OS/2 did not use the AUTOEXEC.BAT file, instead using startup.cmd.