Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
AUTOEXEC.BAT
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
{{Short description|Specifies initial commands run under DOS-type operating systems}} {{Use dmy dates|date=April 2019|cs1-dates=y}} {{Use list-defined references|date=January 2022}} '''<code>AUTOEXEC.BAT</code>''' 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 [[command (computing)|commands]] on system startup; the filename was coined in response to the [[8.3 filename]] limitations of the [[File Allocation Table|FAT]] file system family. ==Usage== <code>AUTOEXEC.BAT</code> 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,<ref name="Microsoft_288997"/> but this can be worked around.<ref name="Multiboot"/> The filename was also used by {{Interlanguage link|Disk Control Program|de}} (DCP), an MS-DOS derivative by the former East-German [[VEB Robotron]].<ref name="DCP_2016"/> 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 <code>/P:filename</code> is given and no default <code>AUTOEXEC.BAT</code> is found, <code>[[COMMAND.COM]]</code> will look for a file named <code>KAUTOEXE.BAT</code> instead in order to ensure that the [[DBCS]] frontend drivers will be loaded even without properly set up <code>CONFIG.SYS</code> and <code>AUTOEXEC.BAT</code> files.<ref name="Paul_2001_KAUTOEXE.BAT"/> Under DOS, the file is executed by the primary copy of the command-line processor (typically <code>COMMAND.COM</code>) once the operating system has booted and the <code>[[CONFIG.SYS]]</code> file processing has finished. While DOS by itself provides no means to pass [[batch file parameter]]s to <code>COMMAND.COM</code> for <code>AUTOEXEC.BAT</code> processing, the alternative command-line processor [[4DOS]] supports a <code>4DOS.INI</code> ''<code>AutoExecParams</code>'' directive and <code>//AutoExecParams=</code> startup option to define such parameters.<ref name="4DOS_8.00_HELP"/> Under [[Concurrent DOS]], [[Multiuser DOS]] and [[REAL/32]], three initial parameters will be passed to either the corresponding <code>STARTxxy.BAT</code> (if it exists) or the generic <code>AUTOEXEC.BAT</code> startup file, <code>%1</code> holds the virtual console number,<ref name="DigitalResearch_1989_PrinterSpool"/> <code>%2</code> the 2-digit <!-- PC -->terminal number (xx) (with 00 being the main console) and <code>%3</code> the 1-digit session<!-- relative virtual console --> number (y).<ref name="Novell_1993_FYI.M.1901"/> [[Windows NT]] and its descendants [[Windows XP]] and [[Windows Vista]] parse <code>AUTOEXEC.BAT</code> when a user logs on. As with Windows Me, anything other than setting environment variables is ignored.<ref name="Microsoft_124551"/> Unlike <code>CONFIG.SYS</code>, the commands in <code>AUTOEXEC.BAT</code> 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. <code>AUTOEXEC.BAT</code> 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: * [[Virus scanner]]s * Disk caching software * Mouse drivers * Keyboard drivers * CD drivers * Miscellaneous other drivers ==Example== In early versions of DOS, <code>AUTOEXEC.BAT</code> was by default very simple. The <code>[[DATE (command)|DATE]]</code> and <code>[[TIME (command)|TIME]]</code> commands were necessary as early [[IBM Personal Computer|PC]] and [[IBM Personal Computer XT|XT]] class machines did not have a battery backed-up [[real-time clock]] as default. <syntaxhighlight lang="dosbatch"> @ECHO OFF CLS DATE TIME VER </syntaxhighlight> In non-US environments, the keyboard driver (like <code>KEYB FR</code> 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 <code>AUTOEXEC.BAT</code> configuration, consisting only of essential commands: <syntaxhighlight lang="dosbatch"> @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 </syntaxhighlight> This configuration sets common environment variables, loads a disk cache, places common directories into the default [[PATH (DOS command)|PATH]], and initializes the DOS mouse / keyboard drivers. The <code>[[PROMPT (DOS command)|PROMPT]]</code> command sets the [[prompt (computing)|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 <code>CONFIG.SYS</code>, and programs were loaded in the <code>AUTOEXEC.BAT</code> file. Some devices, such as mice, could be loaded either as a device driver in <code>CONFIG.SYS</code>, or as a [[Terminate-and-stay-resident program|TSR]] in <code>AUTOEXEC.BAT</code>, depending upon the manufacturer.<ref name="Microsoft_96706"/> 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. <syntaxhighlight lang="dosbatch"> @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 </syntaxhighlight> The <code>GOTO %CONFIG%</code> line informs DOS to look up menu entries that were defined within <code>CONFIG.SYS</code>. Then, these profiles are named here and configured with the desired specific drivers and utilities. At the desired end of each specific configuration, a <code>GOTO</code> command redirects DOS to the <code>:END</code> section. Lines after <code>:END</code> will be used by all profiles. ==Dual-booting DOS and Windows 9x== When installing [[Windows 95]] over a preexisting DOS/Windows install, <code>CONFIG.SYS</code> and <code>AUTOEXEC.BAT</code> are renamed to <code>CONFIG.DOS</code> and <code>AUTOEXEC.DOS</code>. This is intended to ease dual booting between Windows 9x and DOS. When booting into DOS, they are temporarily renamed <code>CONFIG.SYS</code> and <code>AUTOEXEC.BAT</code>. Backups of the Windows 9x versions are made as <code>.W40</code> files. Windows 9x also installs <code>[[MSDOS.SYS]]</code>, a configuration file, which will not boot Windows 95/98 if parameter<code>BOOTGUI=0</code> is loaded, and instead a DOS prompt will appear on the screen (Windows can still be loaded by calling the <code>WIN</code> 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 <code>WIN</code> at the DOS prompt. When installing [[Caldera (company)|Caldera]] [[DR-DOS]] 7.02 and higher, the Windows version retains the name <code>AUTOEXEC.BAT</code>, while the file used by the DR-DOS <code>COMMAND.COM</code> is named <code>AUTODOS7.BAT</code>, referred to by the startup parameter <code>/P:filename.ext</code> in the [[SHELL directive]]. It also differentiates the <code>[[CONFIG.SYS]]</code> file by using the name <code>DCONFIG.SYS</code>.<ref name="Caldera_1998_USER_1"/><ref name="Caldera_1998_USER"/><ref name="Novell_1993_FYI.M.1909"/> == OS/2 == The equivalent to <code>AUTOEXEC.BAT</code> under [[OS/2]] is the OS/2 <code>STARTUP.CMD</code> file. Genuine DOS sessions booted under OS/2 continue to use <code>AUTOEXEC.BAT</code>. == Windows NT== On [[Windows NT]] and its derivatives, [[Windows 2000]], [[Windows Server 2003]] and [[Windows XP]], the equivalent file is called <code>AUTOEXEC.NT</code> and is located in the <code>[[%SystemRoot%]]\system32</code> 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 <code>AUTOEXEC.BAT</code> file may often be found on Windows NT in the root directory of the boot drive. Windows only considers the <code>[[SET (DOS command)|SET]]</code> and <code>[[PATH (DOS command)|PATH]]</code> 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 [[File Allocation Table|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 == * [[COMMAND.COM]] * [[IBMBIO.COM]] / [[IO.SYS]] * [[IBMDOS.COM]] / [[MSDOS.SYS]] * [[SHELL (CONFIG.SYS directive)]] * [[CONFIG.SYS]] * [[autorun.inf]] ==References== {{reflist|refs= <ref name="Microsoft_288997">{{cite web |title="Subst" Command Does Not Work in Autoexec.bat File in Windows Millennium Edition |publisher=[[Microsoft]] |id=KB288997. Q288997 |date=2007-01-31 |version=Revision 1.3 |url=http://support.microsoft.com/kb/288997/en-us |url-status = dead|access-date=2007-07-04 |archive-url=https://web.archive.org/web/20110524053822/http://support.microsoft.com/kb/288997/en-us |archive-date=2011-05-24}}</ref> <ref name="Multiboot">{{cite web |author-first=V. |author-last=Ashumov |title=Some features of MS-DOS 8.0 |date=2017 |orig-year=2007 |url=http://www.multiboot.ru/msdos8.htm |access-date=2010-11-21 |url-status = live|archive-url=https://web.archive.org/web/20101022205112/http://www.multiboot.ru/msdos8.htm |archive-date=2010-10-22}}</ref> <ref name="Paul_2001_KAUTOEXE.BAT">{{cite newsgroup |title=System file settings |author-first=Matthias R. |author-last=Paul |newsgroup=comp.os.msdos.programmer |date=2001-10-25 |url=https://groups.google.com/d/msg/comp.os.msdos.programmer/OWwTYzBfHWs/G8Wl1FOCfa0J |access-date=2014-08-06 |url-status = live|archive-url=https://archive.today/20170910164616/https://groups.google.com/forum/%23!msg/comp.os.msdos.programmer/OWwTYzBfHWs/G8Wl1FOCfa0J |archive-date=2017-09-10 |quote=[…] [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. […]}}</ref> <ref name="4DOS_8.00_HELP">{{cite book |title=4DOS 8.00 online help |title-link=4DOS 8.00 |author-first1=Hardin |author-last1=Brothers |author-first2=Tom |author-last2=Rawson |author-link2=Tom Rawson |author-first3=Rex C. |author-last3=Conn |author-link3=Rex C. Conn |author-first4=Matthias R. |author-last4=Paul |author-first5=Charles E. |author-last5=Dye |author-first6=Luchezar I. |author-last6=Georgiev |date=2002-02-27}}</ref> <ref name="DigitalResearch_1989_PrinterSpool">{{cite book |title=Concurrent DOS Multiuser/Multitasking Operating System - Print Spooler User's Guide |publisher=[[Digital Research]] |date=1989-02-01 |url=http://bitsavers.informatik.uni-stuttgart.de/pdf/digitalResearch/concurrent/1172-2005-001_Concurrent_DOS_Print_Spooler_Users_Guide_Feb89.pdf |access-date=2014-08-12 |url-status = live|archive-url=https://web.archive.org/web/20161105164541/http://bitsavers.informatik.uni-stuttgart.de/pdf/digitalResearch/concurrent/1172-2005-001_Concurrent_DOS_Print_Spooler_Users_Guide_Feb89.pdf |archive-date=2016-11-05}}</ref> <ref name="Novell_1993_FYI.M.1901">{{cite web |title=FYI - Configuring CSPOOL |publisher=[[Novell]] |date=1992-12-29 |id=FYI.M.1901 |url=http://cd.textfiles.com/netwaresl/NOV_INFO/RNW93/10JAN93.MON |access-date=2014-08-12 |url-status = live|archive-url=https://web.archive.org/web/20161105164756/http://cd.textfiles.com/netwaresl/NOV_INFO/RNW93/10JAN93.MON |archive-date=2016-11-05}}</ref> <ref name="Microsoft_124551">{{cite web |title=INFO: Configuring Parsing of the AUTOEXEC.BAT |date=2007-03-20 |orig-year=2002-06-11 |id=Q124551 |edition=1 |publisher=[[Microsoft]] |url=https://jeffpar.github.io/kbarchive/kb/124/Q124551/<!-- http://support.microsoft.com/kb/124551 --> |access-date=2017-09-10 |url-status = dead|archive-url=https://web.archive.org/web/20190421155510/https://jeffpar.github.io/kbarchive/kb/124/Q124551/ |archive-date=2019-04-21}}</ref> <ref name="Microsoft_96706">{{cite web |title=Mouse Doesn't Work with MS-DOS Shell |publisher=[[Microsoft]] |id=KB96706. Q96706 |date=2007 |orig-year=1994 |url=http://support.microsoft.com/kb/96706 |url-status = dead|access-date=2006-10-15 |archive-url=https://web.archive.org/web/20070311095112/http://support.microsoft.com/kb/96706 |archive-date=2007-03-11}}</ref> <ref name="Caldera_1998_USER_1">{{cite book |title=Caldera DR-DOS 7.02 User Guide |chapter=Chapter 1: Introduction to DR-DOS |publisher=[[Caldera, Inc.]] |date=1998 |orig-year=1993, 1997 |chapter-url=http://www.drdos.com/dosdoc/usergeng/01ugch1.htm |access-date=2013-08-10 |url-status = dead|archive-url=https://web.archive.org/web/20161105170240/http://www.drdos.com/dosdoc/usergeng/01ugch1.htm |archive-date=2016-11-05}}</ref> <ref name="Caldera_1998_USER">{{cite book |title=Caldera DR-DOS 7.02 User Guide |publisher=[[Caldera, Inc.]] |date=1998 |orig-year=1993, 1997 |url=http://www.drdos.net/documentation/usergeng/uglontoc.htm |access-date=2013-08-10 |url-status = dead|archive-url=https://web.archive.org/web/20161105165004/http://www.drdos.net/documentation/usergeng/uglontoc.htm |archive-date=2016-11-05}}</ref> <ref name="Novell_1993_FYI.M.1909">{{cite web |title=FYI - Configuring LOADER.COM for Multiple Operating System Boots - Installing DR DOS on NEC DOS 3.3 Partitions |publisher=[[Novell]] |date=1993-01-05 |id=FYI.M.1909 |url=http://cd.textfiles.com/netwaresl/NOV_INFO/RNW93/10JAN93.MON |access-date=2014-08-12 |url-status = live|archive-url=https://web.archive.org/web/20161105165452/http://cd.textfiles.com/netwaresl/NOV_INFO/RNW93/10JAN93.MON |archive-date=2016-11-05}}</ref> <ref name="DCP_2016">{{cite web |title=Betriebssystem DCP |author-first1=Rüdiger |author-last1=Kurth |author-first2=Martin |author-last2=Groß |author-first3=Henry |author-last3=Hunger |date=2016-11-29 |orig-year=2007 |language=de |website=www.robotrontechnik.de |url=http://www.robotrontechnik.de/html/software/dcp.htm |access-date=2019-04-28 |url-status = live|archive-url=https://web.archive.org/web/20190403061152/http://www.robotrontechnik.de/html/software/dcp.htm |archive-date=2019-04-03}}</ref> }} {{DOS system files}} {{DEFAULTSORT:Autoexec.Bat}} [[Category:DOS files]] [[Category:Configuration files]] [[Category:MSX-DOS]]
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)
Pages transcluded onto the current version of this page
(
help
)
:
Template:DOS system files
(
edit
)
Template:Interlanguage link
(
edit
)
Template:Reflist
(
edit
)
Template:Short description
(
edit
)
Template:Use dmy dates
(
edit
)
Template:Use list-defined references
(
edit
)