HOME

TheInfoList



OR:

AUTOEXEC.BAT is a system file that was originally on DOS-type operating systems. It is a plain-text
batch file A batch file is a Scripting language, script file in DOS, OS/2 and Microsoft Windows. It consists of a series of Command (computing), commands to be executed by the command-line interpreter, stored in a plain text file. A batch file may contain a ...
in the
root directory In a Computing, computer file system, and primarily used in the Unix and Unix-like operating systems, the root directory is the first or top-most Directory (computing), directory in a hierarchy. It can be likened to the trunk of a Tree (data st ...
of the boot device. The name of the file is an abbreviation of "automatic execution", which describes its function in automatically executing commands on system startup; the filename was coined in response to the 8.3 filename limitations of the
FAT In nutrition science, nutrition, biology, and chemistry, fat usually means any ester of fatty acids, or a mixture of such chemical compound, compounds, most commonly those that occur in living beings or in food. The term often refers specif ...
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 95 Windows 95 is a consumer-oriented operating system developed by Microsoft and the first of its Windows 9x family of operating systems, released to manufacturing on July 14, 1995, and generally to retail on August 24, 1995. Windows 95 merged ...
and
Windows 98 Windows 98 is a consumer-oriented operating system developed by Microsoft as part of its Windows 9x family of Microsoft Windows operating systems. It was the second operating system in the 9x line, as the successor to Windows 95. It was Software ...
.
Windows Me Windows Me (Millennium Edition) is an operating system developed by Microsoft as part of its Windows 9x family of Microsoft Windows operating systems. It was the successor to Windows 98, and was released to manufacturing on June 19, 2000, and t ...
only parses environment variables as part of its attempts to reduce legacy dependencies, but this can be worked around. The filename was also used by (DCP), an MS-DOS derivative by the former East-German VEB Robotron. In Korean editions of MS-DOS/PC DOS version 4.01 and higher (except for PC DOS 7 and 2000), if the current country code is set to 82 (for Korea) and no /P:filename is given and no default AUTOEXEC.BAT is found, COMMAND.COM will look for a file named KAUTOEXE.BAT instead in order to ensure that the DBCS frontend drivers will be loaded even without properly set up CONFIG.SYS and AUTOEXEC.BAT files. Under DOS, the file is executed by the primary copy of the command-line processor (typically COMMAND.COM) once the operating system has booted and the CONFIG.SYS file processing has finished. While DOS by itself provides no means to pass batch file parameters to COMMAND.COM for AUTOEXEC.BAT processing, the alternative command-line processor 4DOS supports a 4DOS.INI ''AutoExecParams'' directive and //AutoExecParams= startup option to define such parameters. Under Concurrent DOS,
Multiuser DOS Multiuser DOS is a real-time multi-user multi-tasking operating system for IBM PC-compatible microcomputers. An evolution of the older Concurrent CP/M-86, Concurrent DOS and Concurrent DOS 386 operating systems, it was originally developed by ...
and REAL/32, three initial parameters will be passed to either the corresponding STARTxxy.BAT (if it exists) or the generic AUTOEXEC.BAT startup file, %1 holds the virtual console number, %2 the 2-digit terminal number (xx) (with 00 being the main console) and %3 the 1-digit session number (y).
Windows NT Windows NT is a Proprietary software, proprietary Graphical user interface, graphical operating system produced by Microsoft as part of its Windows product line, the first version of which, Windows NT 3.1, was released on July 27, 1993. Original ...
and its descendants
Windows XP Windows XP is a major release of Microsoft's Windows NT operating system. It was released to manufacturing on August 24, 2001, and later to retail on October 25, 2001. It is a direct successor to Windows 2000 for high-end and business users a ...
and
Windows Vista Windows Vista is a major release of the Windows NT operating system developed by Microsoft. It was the direct successor to Windows XP, released five years earlier, which was then the longest time span between successive releases of Microsoft W ...
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 An environment variable is a user-definable value that can affect the way running processes will behave on a computer. Environment variables are part of the environment in which a process runs. For example, a running process can query the va ...
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 * Mouse drivers * Keyboard drivers * CD drivers * Miscellaneous other drivers


Example

In early versions of DOS, AUTOEXEC.BAT was by default very simple. The DATE and
TIME Time is the continuous progression of existence that occurs in an apparently irreversible process, irreversible succession from the past, through the present, and into the future. It is a component quantity of various measurements used to sequ ...
commands were necessary as early PC and XT class machines did not have a battery backed-up real-time clock as default. @ECHO OFF CLS DATE TIME VER In non-US environments, the keyboard driver (like KEYB FR 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 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 This configuration sets common environment variables, loads a disk cache, places common directories into the default PATH, and initializes the DOS mouse / keyboard drivers. The PROMPT command sets the prompt to "C:\>" (when the
working directory In computing, the working directory of a process is a directory of a hierarchical file system, if any, dynamically associated with the process. It is sometimes called the current working directory (CWD), e.g. the BSD getcwd function, or just c ...
is the root of the C drive) instead of simply "C>" (the default prompt, indicating only the working drive and not the directory therein). In general, device drivers were loaded in CONFIG.SYS, and programs were loaded in the AUTOEXEC.BAT file. Some devices, such as mice, could be loaded either as a device driver in CONFIG.SYS, or as a TSR in AUTOEXEC.BAT, depending upon the manufacturer. In MS-DOS 6.0 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. @ECHO OFF PROMPT $P$G PATH C:\DOS;C:\WINDOWS SET TEMP=C:\TEMP SET BLASTER=A220 I7 D1 T2 GOTO %CONFIG% :WIN LH SMARTDRV.EXE LH MOUSE.COM /Y WIN GOTO END :XMS LH SMARTDRV.EXE LH DOSKEY GOTO END :END 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.


Dual-booting DOS and Windows 9x

When installing
Windows 95 Windows 95 is a consumer-oriented operating system developed by Microsoft and the first of its Windows 9x family of operating systems, released to manufacturing on July 14, 1995, and generally to retail on August 24, 1995. Windows 95 merged ...
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 9x and DOS. When booting into DOS, they are temporarily renamed CONFIG.SYS and AUTOEXEC.BAT. Backups of the Windows 9x versions are made as .W40 files. Windows 9x also installs MSDOS.SYS, a configuration file, which will not boot Windows 95/98 if parameterBOOTGUI=0 is loaded, and instead a DOS prompt will appear on the screen (Windows can still be loaded by calling the WIN command (file WIN.COM). 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 A caldera ( ) is a large cauldron-like hollow that forms shortly after the emptying of a magma chamber in a volcanic eruption. An eruption that ejects large volumes of magma over a short period of time can cause significant detriment to the str ...
DR-DOS DR-DOS is a disk operating system for IBM PC compatibles, originally developed by Gary A. Kildall's Digital Research, Inc. and derived from Concurrent PC DOS 6.0, which was an advanced successor of CP/M-86. Upon its introduction in 198 ...
7.02 and higher, the Windows version retains the name AUTOEXEC.BAT, while the file used by the DR-DOS COMMAND.COM is named AUTODOS7.BAT, referred to by the startup parameter /P:filename.ext in the SHELL directive. It also differentiates the CONFIG.SYS file by using the name DCONFIG.SYS.


OS/2

The equivalent to AUTOEXEC.BAT under
OS/2 OS/2 is a Proprietary software, proprietary computer operating system for x86 and PowerPC based personal computers. It was created and initially developed jointly by IBM and Microsoft, under the leadership of IBM software designer Ed Iacobucci, ...
is the OS/2 STARTUP.CMD file. Genuine DOS sessions booted under OS/2 continue to use AUTOEXEC.BAT.


Windows NT

On
Windows NT Windows NT is a Proprietary software, proprietary Graphical user interface, graphical operating system produced by Microsoft as part of its Windows product line, the first version of which, Windows NT 3.1, was released on July 27, 1993. Original ...
and its derivatives,
Windows 2000 Windows 2000 is a major release of the Windows NT operating system developed by Microsoft, targeting the server and business markets. It is the direct successor to Windows NT 4.0, and was Software release life cycle#Release to manufacturing (RT ...
,
Windows Server 2003 Windows Server 2003, codenamed "Whistler Server", is the sixth major version of the Windows NT operating system produced by Microsoft and the first server version to be released under the Windows Server brand name. It is part of the Windows NT ...
and
Windows XP Windows XP is a major release of Microsoft's Windows NT operating system. It was released to manufacturing on August 24, 2001, and later to retail on October 25, 2001. It is a direct successor to Windows 2000 for high-end and business users a ...
, 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 a 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 Set, The Set, SET or SETS may refer to: Science, technology, and mathematics Mathematics *Set (mathematics), a collection of elements *Category of sets, the category whose objects and morphisms are sets and total functions, respectively Electro ...
and PATH statements which it contains, in order to define
environment variable An environment variable is a user-definable value that can affect the way running processes will behave on a computer. Environment variables are part of the environment in which a process runs. For example, a running process can query the va ...
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 In nutrition science, nutrition, biology, and chemistry, fat usually means any ester of fatty acids, or a mixture of such chemical compound, compounds, most commonly those that occur in living beings or in food. The term often refers specif ...
-formatted) or to keep the variables across a reinstall. This is an exotic usage today so the file usually remains empty. The Tweak UI applet from the Microsoft PowerToys collection allows to control this feature (''Parse AUTOEXEC.BAT at logon'').


See also

* COMMAND.COM * IBMBIO.COM / IO.SYS * IBMDOS.COM / MSDOS.SYS * SHELL (CONFIG.SYS directive) * CONFIG.SYS * autorun.inf


References

{{DEFAULTSORT:Autoexec.Bat DOS files Configuration files MSX-DOS