Vous êtes sur la page 1sur 21

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. 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] 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.[3] 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:

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. The date and time commands were necessary as early PC and XT class machines did not have a battery backedup Real Time Clock as default. echo off cls date time ver 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: @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. The prompt command sets the command prompt to "C:\>" instead of simply "C>". 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.[4]

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 CDROM). 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) @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. 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 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 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,[5] 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 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. 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 the loader is named file AUTODOS7.BAT. by using the It also name

differentiates DCONFIG.SYS.[ OS/2 / NT

CONFIG.SYS

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. Some Autoexec Commands Any MS-DOS command you use at the command prompt can also be put in a batch program. In addition, the following MS-DOS commands are specially designed for batch programs: paus call for e choic got rem e o shift echo if

CONFIG.SYS Commands The CONFIG.SYS file is a text file that contains special commands. These commands configure your computer's hardware

components so that MS-DOS and applications can use them. When MS-DOS starts, it carries out the commands in the CONFIG.SYS file. Typically, the CONFIG.SYS file is located in the root directory of drive C. The following CONFIG.SYS commands can be used only in the CONFIG.SYS file: drivpar numloc buffers m country device devicehig install h lastdriv dos e The following commands are commonly used in the CONFIG.SYS file and can also be typed at the command prompt: brea k rem set s fcbs files k shell stacks switche

The following special CONFIG.SYS commands are used only to define multiple configurations within the CONFIG.SYS file: menuite include m menucolor submenu menudefaul t For more information about defining multiple configurations, see Commands for Defining Multiple Configurations. The CONFIG.SYS file can also contain the following special characters: Specifies that the current line is a descriptive comment and should not be carried out. Insert this character at the beginning ; of the line. (You can also insert a comment by using the rem command.) ? Specifies that MS-DOS is to ask for confirmation before carrying out the current command. Insert this character just before the equal sign (=). For example, to have MS-DOS ask for

confirmation before carrying out the dos=high command, you

would change the command to read dos?=high. Bypassing CONFIG.SYS and AUTOEXEC.BAT Commands If you are having system problems that you suspect are caused by one or more commands in your CONFIG.SYS file, you might want to bypass some or all of the commands in your CONFIG.SYS file. To bypass all the commands in your CONFIG.SYS and

AUTOEXEC.BAT files, press the F5 key immediately after starting your computer, when you see the text "Now starting MS-DOS...". To bypass individual CONFIG.SYS commands, press the F8 key instead. MS-DOS will then prompt you to carry out or bypass each CONFIG.SYS command. To carry out all remaining startup commands, press F5. To bypass all remaining startup commands, press ESC. To disable this feature, add the switches /n command to your CONFIG.SYS file. For more information about your CONFIG.SYS file, see the chapter "Configuring Your System" in the MS-DOS 6 User's Guide.

Top Of Page Device Drivers The following installable device drivers are provided with MS-DOS: ANSI.SYS CHKSTATE.SY INTERLNK.EXE S DBLSPACE.SY POWER.EXE S DISPLAY.SYS DRIVER.SYS EGA.SYS E EMM386.EXE The files COUNTRY.SYS and KEYBOARD.SYS are not device drivers. They are data files for the country and keyb commands, respectively. Do not try to load either of these files with the device command. If you do, your system halts, and you cannot restart MS-DOS. For information about loading COUNTRY.SYS, see the country command. For information about loading RAMDRIVE.SYS SETVER.EXE SMARTDRV.EX HIMEM.SYS

KEYBOARD.SYS, see the keyb command.

Top Of Page International Commands The following commands are useful when changing countryspecific settings and character sets (code pages): chcp mode

countr nlsfun y keyb Top Of Page Commands for Defining Multiple Configurations A single CONFIG.SYS file can define several different system configurations. To define multiple configurations, you use the following special CONFIG.SYS commands: menuite include m menucolor submenu menudefaul t To define multiple configurations, follow these general steps: c

1. Define a startup menu in the CONFIG.SYS file by using a [menu] header followed by one or more menuitem commands. The menudefault, menucolor and submenu commands can be used to define special characteristics of the startup menu. 2. Create a configuration block in the CONFIG.SYS file for each configuration you want. A configuration block begins with a block header a name surrounded by square brackets. To each block, add the CONFIG.SYS commands that you want MS-DOS to carry out when that configuration is selected from the startup menu. 3. (Optional) In the AUTOEXEC.BAT file, use batch commands such as goto and if to have MS-DOS carry out different AUTOEXEC.BAT configuration. When a configuration is selected from the startup menu, MS-DOS defines an environment variable named CONFIG and sets it to the name of the selected configuration block. To have MS-DOS carry out different sets of commands for different CONFIG values, add a goto %config% command to your AUTOEXEC.BAT file. commands depending on the startup

For more information about defining multiple configurations, see the chapter "Configuring Your System" in the MS-DOS 6 User's Guide. Defining Multiple Configurations in Your CONFIG.SYS File The following CONFIG.SYS file defines two configurations: [Menu] menuitem=Steve menuitem=Lisa [Common] dos=high buffers=15 device=c:\dos\himem.sys [Steve] files=20 device=c:dos\emm386 2048 [Lisa]

files=40 device=c:\net\network.sys [Common] This CONFIG.SYS file configures the computer for either Steve or Lisa. For both configurations, MS-DOS carries out the three commands in the first [common] section: dos=high,

buffers=15, and device=c:\dos\himem.sys. Steve uses a desktop publishing program that requires expanded memory, so his configuration includes a command for EMM386. He does not use the network. Lisa uses the network but not desktop publishing. Her configuration starts the network driver. Defining Multiple Configurations in Your AUTOEXEC.BAT File When a configuration is selected from the startup menu, MS-DOS defines an environment variable named CONFIG and sets it to the name of the selected configuration block. In the AUTOEXEC.BAT file, you can use the goto command to have MS-DOS carry out different sets of commands for different CONFIG values.

The following AUTOEXEC.BAT file uses the goto command with the CONFIG variable to carry out different sets of commands. This AUTOEXEC.BAT file is designed to work with the sample CONFIG.SYS file in the preceding section. c:\dos\smartdrv.exe set temp=c:\temp c:\dos\msav ; Go to the section that matches the current ; value of the CONFIG variable goto %config% :Steve path=c:\dos;c:\deskpub;c:\typeset c:\mouse\mouse.com deskpub` ; now skip Lisa's section & go to end goto end

:Lisa path=c:\dos;c:\network;c:\utility doskey net logon lisa goto end :end When MS-DOS runs this AUTOEXEC.BAT file, it starts SmartDrive, sets the TEMP environment variable, and starts the MS-DOS AntiVirus program. MS-DOS then goes to the section that matches the value of the CONFIG variable. If the name of the selected configuration is "Steve," MS-DOS goes to the Steve section. It then sets the search path for Steve, loads the MOUSE.COM program from the C:\MOUSE directory, and runs the desktop publishing program. The goto end command instructs MS-DOS to skip to the End section; this prevents the commands in the Lisa section from being carried out for Steve's configuration.

If the current configuration is "Lisa," the search path is set differently, MS-DOS runs the Doskey program, and a Logon command instructs the network driver (loaded from the

CONFIG.SYS file) to connect the computer to the network.

Vous aimerez peut-être aussi