An <code>autorun.inf</code> 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 <code>autorun.inf</code> 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

<code>autorun.inf</code> 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.

: The "AutoRun task" is the application specified by the <code>open</code> or <code>shellexecute</code> 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.

: 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 <code>action</code> key to appear as an option within the AutoPlay dialog. Otherwise the AutoRun task is omitted.

: There is a patch available, <code>KB971029</code> for Windows XP and later, that will change AutoRun functionality to this behaviour.

A simple example

This simple autorun.inf file specifies <code>setup.exe</code> as the application to run when AutoRun is activated. The first icon stored within <code>setup.exe</code> itself will represent the drive in Explorer:

<syntaxhighlight lang="ini">

[autorun]

open=setup.exe

icon=setup.exe,0

label=My install CD

</syntaxhighlight>

Sections

Following are the sections and keys allowed in a valid autorun.inf.

  • https://web.archive.org/web/20121220071928/http://dailycupoftech.com/usb-drive-autoruninf-tweaking/
  • https://stackoverflow.com/questions/1232966/auto-run-appilication-while-plug-in-usb-drive
  • http://www.samlogic.net/articles/autorun.htm
  • http://www.makeuseof.com/tag/autolaunch-apps-usb-stick-windows/
  • http://www.autoitscript.com/site/autoit/
  • https://web.archive.org/web/20120505010938/http://go4answers.webhost4life.com/Example/launch-net-application-usb-drive-41597.aspx

ca:Autorun

de:Autorun

es:Autorun

it:Autorun