AUTOEXEC.BAT
Encyclopedia
AUTOEXEC.BAT is a system file found originally on DOS
-type operating systems. It is a plain-text batch file that is located in the root directory
of the boot device. The name of the file stands for "automatic 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.
and Windows 98
. Windows Me
only parses environment variables as part of its attempts to reduce legacy dependencies, but this can be worked around.
Under DOS, the file is executed once the operating system has booted and after the CONFIG.SYS
file has been processed. Windows NT
and its descendants Windows XP
and Windows Vista
parse AUTOEXEC.BAT when a user logs on. As with Windows Me, anything other than setting environment variables is ignored. Unlike CONFIG.SYS, the commands in AUTOEXEC.BAT can be entered at the interactive command line interpreter. They are just standard commands that the computer operator wants to be executed automatically whenever the computer is started, and can include other batch files.
AUTOEXEC.BAT is most often used to set environment variable
s such as keyboard, soundcard, printer, and temporary file locations. It is also used to initiate low level system utilities, such as the following:
class machines did not have a battery backed-up Real Time Clock as default.
In non US environments the keyboard driver (like KEYBFR for the French keyboard) was also included. 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:
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. The
In general, .SYS files were called in CONFIG.SYS, and .EXE
programs such as the popular disk caching software SmartDrive provided by Microsoft with MS-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, depending upon the manufacturer.
Lines prefixed with the string "REM" are comments
(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 (::).
In MS-DOS 6 and higher, a DOS boot menu is configurable. This can be of great help to users who wish to have optimized boot configurations for various programs, such as DOS games and Windows. (continued from CONFIG.SYS
article)
The
. This was due to the archaic design of the original x86 processor, which was originally only able to address 1024kB, or an effective 640kB 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 8192K 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 LOADHIGH/LH (MS-DOS) or HILOAD (DR-DOS) commands, based upon the EMM386
memory manager
loaded in the CONFIG.SYS files, in order to try to move drivers from the 640K region, into the upper memory area
or the high memory area. 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 disk
s, 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, which could access the entire physical memory of the PC, and relied upon Windows drivers to access hardware. This was also solved by using 32-bit DOS programs and standard VESA drivers for graphics.
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
Windows 9x also installs a fake MSDOS.SYS
file. This file contains some switches that designate how the system will boot, one of which controls whether or not the system automatically goes into Windows. This "BootGUI" option must be set to "0" in order to boot to a DOS prompt. By doing this, the system's operation essentially becomes that of a DOS/Windows pairing like with earlier Windows versions. Windows can be started as desired by typing "WIN" at the DOS prompt.
When installing Caldera
DR-DOS
7.02 and higher, the Windows version retains the name AUTOEXEC.BAT, while the file preferred by the DR-DOS loader is named AUTODOS7.BAT. It also differentiates the CONFIG.SYS
file by using the name DCONFIG.SYS.
and its derivatives, Windows 2000
, Windows Server 2003
and Windows XP
, the equivalent file is called AUTOEXEC.NT and is located in the
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 variable
s 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.
DOS
DOS, short for "Disk Operating System", is an acronym for several closely related operating systems that dominated the IBM PC compatible market between 1981 and 1995, or until about 2000 if one includes the partially DOS-based Microsoft Windows versions 95, 98, and Millennium Edition.Related...
-type operating systems. It is a plain-text batch file that is located in the root directory
Root directory
In computer file systems, the root directory is the first or top-most directory in a hierarchy. It can be likened to the root of a tree — the starting point where all branches originate.-Metaphor:...
of the boot device. The name of the file stands for "automatic execution", which describes its function in automatically executing commands
Command (computing)
In computing, a command is a directive to a computer program acting as an interpreter of some kind, in order to perform a specific task. Most commonly a command is a directive to some kind of command line interface, such as a shell....
on system startup; the portmanteau was coined in response to the 8.3 filename limitations of the FAT
File Allocation Table
File Allocation Table is a computer file system architecture now widely used on many computer systems and most memory cards, such as those used with digital cameras. FAT file systems are commonly found on floppy disks, flash memory cards, digital cameras, and many other portable devices because of...
file system family.
Usage
AUTOEXEC.BAT is read upon startup by all versions of DOS, including MS-DOS version 7.x as used in Windows 95Windows 95
Windows 95 is a consumer-oriented graphical user interface-based operating system. It was released on August 24, 1995 by Microsoft, and was a significant progression from the company's previous Windows products...
and Windows 98
Windows 98
Windows 98 is a graphical operating system by Microsoft. It is the second major release in the Windows 9x line of operating systems. It was released to manufacturing on 15 May 1998 and to retail on 25 June 1998. Windows 98 is the successor to Windows 95. Like its predecessor, it is a hybrid...
. Windows Me
Windows Me
Windows Millennium Edition, or Windows Me , is a graphical operating system released on September 14, 2000 by Microsoft, and was the last operating system released in the Windows 9x series. Support for Windows Me ended on July 11, 2006....
only parses environment variables as part of its attempts to reduce legacy dependencies, but this can be worked around.
Under DOS, the file is executed once the operating system has booted and after the CONFIG.SYS
CONFIG.SYS
CONFIG.SYS is the primary configuration file for the DOS, OS/2 as well as similar operating systems. It is a special file that contains setup or configuration instructions for the computer system.- Usage :...
file has been processed. Windows NT
Windows NT
Windows NT is a family of operating systems produced by Microsoft, the first version of which was released in July 1993. It was a powerful high-level-language-based, processor-independent, multiprocessing, multiuser operating system with features comparable to Unix. It was intended to complement...
and its descendants Windows XP
Windows XP
Windows XP is an operating system produced by Microsoft for use on personal computers, including home and business desktops, laptops and media centers. First released to computer manufacturers on August 24, 2001, it is the second most popular version of Windows, based on installed user base...
and Windows Vista
Windows Vista
Windows Vista is an operating system released in several variations developed by Microsoft for use on personal computers, including home and business desktops, laptops, tablet PCs, and media center PCs...
parse AUTOEXEC.BAT when a user logs on. As with Windows Me, anything other than setting environment variables is ignored. Unlike CONFIG.SYS, the commands in AUTOEXEC.BAT can be entered at the interactive command line interpreter. They are just standard commands that the computer operator wants to be executed automatically whenever the computer is started, and can include other batch files.
AUTOEXEC.BAT is most often used to set environment variable
Environment variable
Environment variables are a set of dynamic named values that can affect the way running processes will behave on a computer.They can be said in some sense to create the operating environment in which a process runs...
s 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
Example
In early versions of DOS, AUTOEXEC.BAT was by default extremely simple. ThedateTime and dateIn computing, time and date are commands that are used to display and set the current time and date of the operating system. Both commands are available in DOS, OS/2 and Microsoft Windows command line interpreters such as COMMAND.COM, cmd.exe and 4DOS/4NT. The Unix command date displays both the...
and timeTime and dateIn computing, time and date are commands that are used to display and set the current time and date of the operating system. Both commands are available in DOS, OS/2 and Microsoft Windows command line interpreters such as COMMAND.COM, cmd.exe and 4DOS/4NT. The Unix command date displays both the...
commands were necessary as early PC and XTIBM Personal Computer XT
The IBM Personal Computer XT, often shortened to the IBM XT, PC XT, or simply XT, was IBM's successor to the original IBM PC. It was released as IBM Machine Type number 5160 on March 8, 1983, and came standard with a hard drive...
class machines did not have a battery backed-up Real Time Clock as default.
In non US environments the keyboard driver (like KEYBFR for the French keyboard) was also included. 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:
This configuration sets common environment variables, loads the disk cache SmartDrive
SmartDrive
SmartDrive was a disk caching program that shipped with MS-DOS versions 4.01 through 6.22 and Windows 3.x. It improved disk transfer rates by storing frequently accessed data in the main memory. Early versions of SmartDrive were loaded through a CONFIG.SYS device driver named SMARTDRV.SYS...
on line six, places common directories into the default path
Path (computing)
A path, the general form of a filename or of a directory name, specifies a unique location in a file system. A path points to a file system location by following the directory tree hierarchy expressed in a string of characters in which path components, separated by a delimiting character, represent...
, and initializes the DOS mouse / keyboard drivers, before starting Windows. The
prompt
command sets the command prompt to "C:\>" instead of simply "C>".In general, .SYS files were called in CONFIG.SYS, and .EXE
EXE
EXE is the common filename extension denoting an executable file in the DOS, OpenVMS, Microsoft Windows, Symbian, and OS/2 operating systems....
programs such as the popular disk caching software SmartDrive provided by Microsoft with MS-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
COM file
In many computer operating systems, a COM file is a type of executable file; the name is derived from the file name extension .COM. Originally, the term stood for "Command file", a text file containing commands to be issued to the operating system , on many of the Digital Equipment Corporation mini...
in AUTOEXEC.BAT, depending upon the manufacturer.
Lines prefixed with the string "REM" are comments
Comment (computer programming)
In computer programming, a comment is a programming language construct used to embed programmer-readable annotations in the source code of a computer program. Those annotations are potentially significant to programmers but typically ignorable to compilers and interpreters. Comments are usually...
(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 (::).
In MS-DOS 6 and higher, a DOS boot menu is configurable. This can be of great help to users who wish to have optimized boot configurations for various programs, such as DOS games and Windows. (continued from CONFIG.SYS
CONFIG.SYS
CONFIG.SYS is the primary configuration file for the DOS, OS/2 as well as similar operating systems. It is a special file that contains setup or configuration instructions for the computer system.- Usage :...
article)
The
goto %CONFIG%
line informs DOS to look up menu entries that were defined within CONFIG.SYS
. Then, these profiles are named here and configured with the desired specific drivers and utilities. At the desired end of each specific configuration, a goto
command redirects DOS to the :END
section. Lines after :END
will be used by all profiles.Issues
One of the problems with the versions of Windows that ran on top of DOS, was a lack of conventional memoryConventional memory
In DOS memory management, conventional memory, also called base memory, is the first 640 kilobytes of the memory on IBM PC or compatible systems. It is the read-write memory usable by the operating system and application programs...
. This was due to the archaic design of the original x86 processor, which was originally only able to address 1024kB, or an effective 640kB 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 8192K 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 LOADHIGH/LH (MS-DOS) or HILOAD (DR-DOS) commands, based upon the EMM386
EMM386
The name EMM386 was used for the expanded memory managers of both Microsoft's MS-DOS and Digital Research's DR-DOS, which created expanded memory using extended memory on Intel 80386 CPUs. There also is an EMM386.EXE available in FreeDOS....
memory manager
Memory manager
In IBM PC compatible computing, DOS memory management refers to software and techniques employed to give applications access to more than 640K of "conventional memory". The 640kB limit was specific to the IBM PC and close compatibles; other machines running MS-DOS had different limits, for example...
loaded in the CONFIG.SYS files, in order to try to move drivers from the 640K region, into the upper memory area
Upper Memory Area
In DOS memory management, the upper memory area refers to memory between the addresses of 640 KB and 1024 KB in an IBM PC or compatible. IBM reserved the uppermost 384 KB of the 8088 CPU's 1024 KB address space for ROM, RAM on peripherals, and memory-mapped input/output...
or the high memory area. 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 disk
Boot disk
A boot disk is a removable digital data storage medium from which a computer can load and run an operating system or utility program. The computer must have a built-in program which will load and execute a program from a boot disk meeting certain standards.Boot disks are used for:* Operating...
s, 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, which could access the entire physical memory of the PC, and relied upon Windows drivers to access hardware. This was also solved by using 32-bit DOS programs and standard VESA drivers for graphics.
Dual-booting DOS and Win 9x
When installing Windows 95Windows 95
Windows 95 is a consumer-oriented graphical user interface-based operating system. It was released on August 24, 1995 by Microsoft, and was a significant progression from the company's previous Windows products...
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.Windows 9x also installs a fake MSDOS.SYS
MSDOS.SYS
MSDOS.SYS an important system file on MS-DOS and Windows 9x systems. It is run after IO.SYS. In MS-DOS, it contains the core operating system code, the kernel...
file. This file contains some switches that designate how the system will boot, one of which controls whether or not the system automatically goes into Windows. This "BootGUI" option must be set to "0" in order to boot to a DOS prompt. By doing this, the system's operation essentially becomes that of a DOS/Windows pairing like with earlier Windows versions. Windows can be started as desired by typing "WIN" at the DOS prompt.
When installing Caldera
Caldera (company)
Caldera was a US-based software company founded in 1994 to develop Linux- and DOS-based operating system products.- Caldera :Caldera, Inc...
DR-DOS
DR-DOS
DR-DOS is an MS-DOS-compatible operating system for IBM PC-compatible personal computers, originally developed by Gary Kildall's Digital Research and derived from Concurrent PC DOS 6.0, which was an advanced successor of CP/M-86...
7.02 and higher, the Windows version retains the name AUTOEXEC.BAT, while the file preferred by the DR-DOS loader is named AUTODOS7.BAT. It also differentiates the CONFIG.SYS
CONFIG.SYS
CONFIG.SYS is the primary configuration file for the DOS, OS/2 as well as similar operating systems. It is a special file that contains setup or configuration instructions for the computer system.- Usage :...
file by using the name DCONFIG.SYS.
OS/2 / NT
On Windows NTWindows NT
Windows NT is a family of operating systems produced by Microsoft, the first version of which was released in July 1993. It was a powerful high-level-language-based, processor-independent, multiprocessing, multiuser operating system with features comparable to Unix. It was intended to complement...
and its derivatives, Windows 2000
Windows 2000
Windows 2000 is a line of operating systems produced by Microsoft for use on personal computers, business desktops, laptops, and servers. Windows 2000 was released to manufacturing on 15 December 1999 and launched to retail on 17 February 2000. It is the successor to Windows NT 4.0, and is the...
, Windows Server 2003
Windows Server 2003
Windows Server 2003 is a server operating system produced by Microsoft, introduced on 24 April 2003. An updated version, Windows Server 2003 R2, was released to manufacturing on 6 December 2005...
and Windows XP
Windows XP
Windows XP is an operating system produced by Microsoft for use on personal computers, including home and business desktops, laptops and media centers. First released to computer manufacturers on August 24, 2001, it is the second most popular version of Windows, based on installed user base...
, 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 variable
Environment variable
Environment variables are a set of dynamic named values that can affect the way running processes will behave on a computer.They can be said in some sense to create the operating environment in which a process runs...
s 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
File Allocation Table
File Allocation Table is a computer file system architecture now widely used on many computer systems and most memory cards, such as those used with digital cameras. FAT file systems are commonly found on floppy disks, flash memory cards, digital cameras, and many other portable devices because of...
) or to keep the variables across a reinstall. This is an exotic usage today so this file usually remains empty. The TweakUI
TweakUI
Tweak UI is a free user interface customization application first released by Microsoft in 1996 to aid end users in customizing the Microsoft Windows operating system. By itself, it does not do anything that would not otherwise be possible...
applet from the PowerToys collection allows to control this feature (Parse Autoexec.bat at logon).
OS/2
OS/2
OS/2 is a computer operating system, initially created by Microsoft and IBM, then later developed by IBM exclusively. The name stands for "Operating System/2," because it was introduced as part of the same generation change release as IBM's "Personal System/2 " line of second-generation personal...
did not use the AUTOEXEC.BAT file, instead using startup.cmd.
See also
- DOSDOSDOS, short for "Disk Operating System", is an acronym for several closely related operating systems that dominated the IBM PC compatible market between 1981 and 1995, or until about 2000 if one includes the partially DOS-based Microsoft Windows versions 95, 98, and Millennium Edition.Related...
- IBMBIO.COMIBMBIO.COMIBMBIO.COM is the filename of the DOS-BIOS in many DOS operating systems, and as such part of PC-DOS, earlier versions of MS-DOS, and DR DOS 5.0 and higher...
- IBMDOS.COMIBMDOS.COMIBMDOS.COM is the filename of the DOS kernel. It exists in DR-DOS and PC-DOS systems, with MS-DOS using MSDOS.SYS. The file is located in the root directory of the drive containing the operating system....
- IO.SYSIO.SYSIO.SYS is an essential part of MS-DOS and Windows 9x. It contains the default MS-DOS device drivers and the DOS initialization program.- Boot sequence :...
- MSDOS.SYSMSDOS.SYSMSDOS.SYS an important system file on MS-DOS and Windows 9x systems. It is run after IO.SYS. In MS-DOS, it contains the core operating system code, the kernel...
- COMMAND.COMCOMMAND.COMCOMMAND.COM is the filename of the default operating system shell for DOS operating systems and the default command line interpreter on Windows 95, Windows 98 and Windows Me...
- CONFIG.SYSCONFIG.SYSCONFIG.SYS is the primary configuration file for the DOS, OS/2 as well as similar operating systems. It is a special file that contains setup or configuration instructions for the computer system.- Usage :...