AUTOEXEC.BAT

Last updated

AUTOEXEC.BAT is a system file that was originally on DOS-type operating systems. It is a plain-text batch file in the root directory 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 file system family.

Contents

Usage

AUTOEXEC.BAT is read upon startup by all versions of DOS, including MS-DOS version 7.x as used in Windows 95 and Windows 98. Windows ME only parses environment variables as part of its attempts to reduce legacy dependencies, [1] but this can be worked around. [2]

The filename was also used by Disk Control Program  [ de ] (DCP), an MS-DOS derivative by the former East-German VEB Robotron. [3]

In Korean versions of MS-DOS/PC DOS 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. [4]

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.INIAutoExecParams directive and //AutoExecParams= startup option to define such parameters. [5] Under Concurrent DOS, Multiuser DOS 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, [6] %2 the 2-digit terminal number (xx) (with 00 being the main console) and %3 the 1-digit session number (y). [7]

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. [8] 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 variables such as keyboard, soundcard, printer, and temporary file locations. It is also used to initiate low level system utilities, such as the following:

Example

In early versions of DOS, AUTOEXEC.BAT was by default very simple. The DATE and TIME commands were necessary as early PC and XT class machines did not have a battery backed-up real-time clock as default.

@ECHO OFF CLSDATETIMEVER

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 SETTEMP=C:\TEMP SETBLASTER=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 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. [9]

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 SETTEMP=C:\TEMP SETBLASTER=A220 I7 D1 T2 GOTO%CONFIG%:WIN LH SMARTDRV.EXE LH MOUSE.COM /Y WIN GOTOEND:XMS LH SMARTDRV.EXE LH DOSKEY GOTOEND: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 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 DR-DOS 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. [10] [11] [12]

OS/2

The equivalent to AUTOEXEC.BAT under OS/2 is the OS/2 STARTUP.CMD file. Genuine DOS sessions booted under OS/2 continue to use AUTOEXEC.BAT.

Windows 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 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 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-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

Related Research Articles

<span class="mw-page-title-main">Drive letter assignment</span> Alphabetical assignment to logical drives on computers (e.g., C:\)

In computer data storage, drive letter assignment is the process of assigning alphabetical identifiers to volumes. Unlike the concept of UNIX mount points, where volumes are named and located arbitrarily in a single hierarchical namespace, drive letter assignment allows multiple highest-level namespaces. Drive letter assignment is thus a process of using letters to name the roots of the "forest" representing the file system; each volume holds an independent "tree".

<span class="mw-page-title-main">DR-DOS</span> MS-DOS-like operating system

DR-DOS is a disk operating system for IBM PC compatibles. Upon its introduction in 1988, it was the first DOS that attempted to be compatible with IBM PC DOS and MS-DOS.

<span class="mw-page-title-main">COMMAND.COM</span> Default command line for MS-DOS and Windows 9x

COMMAND.COM is the default command-line interpreter for MS-DOS, Windows 95, Windows 98 and Windows Me. In the case of DOS, it is the default user interface as well. It has an additional role as the usual first program run after boot, hence being responsible for setting up the system by running the AUTOEXEC.BAT configuration file, and being the ancestor of all processes.

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 value of the TEMP environment variable to discover a suitable location to store temporary files, or the HOME or USERPROFILE variable to find the directory structure owned by the user running the process.

<span class="mw-page-title-main">Conventional memory</span> First 640 KB of RAM under DOS

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 directly addressable by the processor for use by the operating system and application programs. As memory prices rapidly declined, this design decision became a limitation in the use of large memory capacities until the introduction of operating systems and processors that made it irrelevant.

<span class="mw-page-title-main">Windows 9x</span> Series of Microsoft Windows computer operating systems

Windows 9x is a generic term referring to a series of Microsoft Windows computer operating systems produced from 1995 to 2000, which were based on the Windows 95 kernel and its underlying foundation of MS-DOS, both of which were updated in subsequent versions. The first version in the 9x series was Windows 95, which was succeeded by Windows 98 and then Windows Me, which was the third and last version of Windows on the 9x line, until the series was superseded by Windows XP.

<span class="mw-page-title-main">Configuration file</span> Software file used to configure the initial settings for a computer program

In computing, configuration files are files used to configure the parameters and initial settings for some computer programs. They are used for user applications, server processes and operating system settings.

CONFIG.SYS is the primary configuration file for the DOS and OS/2 operating systems. It is a special ASCII text file that contains user-accessible setup or configuration directives evaluated by the operating system's DOS BIOS during boot. CONFIG.SYS was introduced with DOS 2.0.

Quarterdeck Expanded Memory Manager (QEMM) is a memory manager produced by Quarterdeck Office Systems in the late 1980s through the late 1990s. It was the most popular third-party memory manager for the MS-DOS and other DOS operating systems.

IO.SYS is an essential part of MS-DOS and Windows 9x. It contains the default MS-DOS device drivers and the DOS initialization program.

<span class="mw-page-title-main">IBMDOS.COM</span> System file (DOS kernel) in PC DOS and DR-DOS

IBMDOS.COM is the filename of the DOS kernel. Loaded and initially invoked by the DOS BIOS in IBMBIO.COM during the boot process, it contains the hardware-independent parts of the operating system, including the embedded FAT12, FAT16 and, in newer versions, the FAT32 file system code, as well as the code to provide the DOS API to applications.

The booting process of Microsoft Windows varies between different releases.

<span class="mw-page-title-main">MSCDEX</span>

MSCDEX or Microsoft CD-ROM Extensions is a software program produced by Microsoft and included with MS-DOS 6.x and certain versions of Windows to provide CD-ROM support. Earlier versions of MSCDEX since 1986 were installable add-ons for MS-DOS 3.1 and higher.

A batch file is a script file in DOS, OS/2 and Microsoft Windows. It consists of a series of commands to be executed by the command-line interpreter, stored in a plain text file. A batch file may contain any command the interpreter accepts interactively and use constructs that enable conditional branching and looping within the batch file, such as IF, FOR, and GOTO labels. The term "batch" is from batch processing, meaning "non-interactive execution", though a batch file might not process a batch of multiple data.

<span class="mw-page-title-main">SpartaDOS X</span> Disk operating system

SpartaDOS X is a disk operating system for the Atari 8-bit family of computers that closely resembles MS-DOS. It was developed and sold by ICD, Inc. in 1987-1993, and many years later picked up by the third-party community SpartaDOS X Upgrade Project, which still maintains the software.

<span class="mw-page-title-main">DOS</span> Group of closely related IBM PC-compatible operating systems

DOS is a family of disk-based operating systems for IBM PC compatible computers. The DOS family primarily consists of IBM PC DOS and a rebranded version, Microsoft's MS-DOS, both of which were introduced in 1981. Later compatible systems from other manufacturers include DR-DOS (1988), ROM-DOS (1989), PTS-DOS (1993), and FreeDOS (1998). MS-DOS dominated the IBM PC compatible market between 1981 and 1995.

<span class="mw-page-title-main">Architecture of Windows 9x</span>

The Windows 9x series of operating systems refers to the monolithic kernel which powers these operating systems. The basic code is similar in function to MS-DOS. As a 16-/32-bit hybrid, it requires support from MS-DOS to operate.

<span class="mw-page-title-main">MS-DOS 7</span> Computer operating system

MS-DOS 7 is a real mode operating system for IBM PC compatibles. Unlike earlier versions of MS-DOS, it was not released separately by Microsoft, but included in the Windows 9x family of operating systems. Windows 95 RTM report it as MS-DOS 7.0, and Windows 95 OSR 2.x and Windows 98 report as 7.1. The real-mode MS-DOS 7.x is contained in the IO.SYS file.

References

  1. ""Subst" Command Does Not Work in Autoexec.bat File in Windows Millennium Edition". Revision 1.3. Microsoft. 2007-01-31. KB288997. Q288997. Archived from the original on 2011-05-24. Retrieved 2007-07-04.
  2. Ashumov, V. (2017) [2007]. "Some features of MS-DOS 8.0". Archived from the original on 2010-10-22. Retrieved 2010-11-21.
  3. Kurth, Rüdiger; Groß, Martin; Hunger, Henry (2016-11-29) [2007]. "Betriebssystem DCP". www.robotrontechnik.de (in German). Archived from the original on 2019-04-03. Retrieved 2019-04-28.
  4. Paul, Matthias R. (2001-10-25). "System file settings". Newsgroup:  comp.os.msdos.programmer. Archived from the original on 2017-09-10. Retrieved 2014-08-06. […] [W]hat's KAUTOEXE.BAT? […] This is a special case in Korean MS-DOS/PC DOS 4.01+. It is still present in MS-DOS 7.10 (Windows 98SE, I'm not sure about 8.0 aka ME), but it vanished in PC DOS 7/2000. If the current country code is 82 […] and […] no /P:filename was specified *and* no default AUTOEXEC.BAT file was found, COMMAND.COM will instead execute a file named KAUTOEXE.BAT, if it exists. Presumably, this is used to ensure that the DBCS frontend drivers are loaded without properly set up CONFIG.SYS or AUTOEXEC.BAT files. […]
  5. Brothers, Hardin; Rawson, Tom; Conn, Rex C.; Paul, Matthias R.; Dye, Charles E.; Georgiev, Luchezar I. (2002-02-27). 4DOS 8.00 online help.
  6. Concurrent DOS Multiuser/Multitasking Operating System - Print Spooler User's Guide (PDF). Digital Research. 1989-02-01. Archived (PDF) from the original on 2016-11-05. Retrieved 2014-08-12.
  7. "FYI - Configuring CSPOOL". Novell. 1992-12-29. FYI.M.1901. Archived from the original on 2016-11-05. Retrieved 2014-08-12.
  8. "INFO: Configuring Parsing of the AUTOEXEC.BAT" (1 ed.). Microsoft. 2007-03-20 [2002-06-11]. Q124551. Archived from the original on 2019-04-21. Retrieved 2017-09-10.
  9. "Mouse Doesn't Work with MS-DOS Shell". Microsoft. 2007 [1994]. KB96706. Q96706. Archived from the original on 2007-03-11. Retrieved 2006-10-15.
  10. "Chapter 1: Introduction to DR-DOS". Caldera DR-DOS 7.02 User Guide. Caldera, Inc. 1998 [1993, 1997]. Archived from the original on 2016-11-05. Retrieved 2013-08-10.
  11. Caldera DR-DOS 7.02 User Guide. Caldera, Inc. 1998 [1993, 1997]. Archived from the original on 2016-11-05. Retrieved 2013-08-10.
  12. "FYI - Configuring LOADER.COM for Multiple Operating System Boots - Installing DR DOS on NEC DOS 3.3 Partitions". Novell. 1993-01-05. FYI.M.1909. Archived from the original on 2016-11-05. Retrieved 2014-08-12.