An autorun.inf file is a text file that can be used by the AutoRun and AutoPlay components of Microsoft Windows operating systems. For the file to be discovered and used by these component, it must be located in the root directory of a volume. As Windows has a case-insensitive view of filenames, the autorun.inf file can be stored as AutoRun.inf or Autorun.INF or any other case combination.
The AutoRun component was introduced in Windows 95 as a way of reducing support costs. AutoRun enabled application CD-ROMs to automatically launch a program which could then guide the user through the installation process. By placing settings in an autorun.inf file, manufacturers could decide what actions were taken when their CD-ROM was inserted. The simplest autorun.inf files have just two settings: one specifying an icon to represent the CD in Windows Explorer (or "My Computer") and one specifying which application to run.
Extra settings have been added in successive versions of Windows to support AutoPlay and other new features.
The autorun.inf file
autorun.inf is an ASCII text file located in the root folder of a CD-ROM or other volume device medium (See AutoPlay device types). The structure is that of a classic Windows .ini file, containing information and commands as "key=value" pairs, grouped into sections. These keys specify:
The name and the location of a program to call when the medium is inserted (the "AutoRun task"). The name of a file that contains an icon that represents the medium in Explorer (instead of the standard drive icon). Commands for the menu that appears when the user right-clicks the drive icon. The default command that runs when the user double-clicks the drive icon. Settings that alter AutoPlay detection routines or search parameters. Settings that indicate the presence of drivers.
Abuse
Autorun.inf has been used to execute a malicious program automatically, without the user knowing. This functionality was removed in Windows 7 and a patch for Windows XP and Vista was released on August 25, 2009 and included in Microsoft Automatic Updates on February 8, 2011.
Inf handling
The mere existence of an autorun.inf file on a medium does not mean that Windows will automatically read it or use its settings. How an inf file is handled depends on the version of Windows in use, the volume drive type and certain Registry settings.
Assuming Registry settings allow AutoRun, then the following autorun.inf handling takes place:
Windows versions prior to Windows XP
On any drive type, the autorun.inf is read, parsed and instructions followed immediately and silently. The "AutoRun task" is the application specified by the open or shellexecute keys. If an AutoRun task is specified it is executed immediately without user interaction. Windows XP, prior to Service Pack 2 Introduction of AutoPlay. Drives of type DRIVE_CDROM invoke AutoPlay if no autorun.inf file is found. Drives of type DRIVE_REMOVABLE do not use the autorun.inf file. Any discovered removable media are handled by AutoPlay. All other handling is as before. XP Service Pack 2 and up (includes Vista) Drives of type DRIVE_FIXED are now handled by AutoPlay. Any specified AutoRun task appears as an option within the AutoPlay dialog together with any text specified by the optional action key. Drives of type DRIVE_REMOVABLE now use autorun.inf but continue to be handled by AutoPlay. Any specified AutoRun task needs to be paired with the mandatory action key to appear as an option within the AutoPlay dialog. Otherwise the AutoRun task is omitted. All other handling is as before. Vista and later The AutoRun task is no longer automatically and silently executed on any drive type. All volumes are handled by AutoPlay which, by default, will present an appropriate dialog to the user. Windows 7, Windows 8, Windows 8.1, Windows 10 For all drive types, except DRIVE_CDROM, the only keys available in the [autorun] section are label and icon. Any other keys in this section will be ignored. Thus only CD and DVD media types can specify an AutoRun task or affect double-click and right-click behaviour. There is a patch available, KB971029 for Windows XP and later, that will change AutoRun functionality to this behaviour.
A simple example
This simple autorun.inf file specifies setup.exe as the application to run when AutoRun is activated. The first icon stored within setup.exe itself will represent the drive in Explorer: