Complete Operation Manual for autorun.inf

by xloong on 2007-11-18 10:24:29

**Night Fire: Summary of Key Points, Almost All Useful Information Included**

This summary is quite comprehensive, covering almost all useful information. Compared to previously collected articles such as "New Writing Methods and Applications of Autorun.inf for Viruses and Defense" and "Completely Preventing Autorun.inf from Auto-Running," it provides significant help for writing, modifying, or eliminating autorun.inf files.

**Author's Note:** Given the scarcity of complete articles online about the functionality of autorun.inf, the author found an English usage guide for autorun.inf in a remote corner of Microsoft's official website. Based on translating this guide and conducting personal experiments, the author wrote this article.

=== Separator ===

### 1. Overview of Autorun.inf

Autorun.inf is a file in Windows that controls the behavior of CDs and must be placed in the root directory of the CD. Some operations also apply to hard drives.

### 2. Disabling Autorun.inf

Autorun.inf can be disabled. The method is as follows:

Click Start -> Run, and in the text box, input `regedit` or `regedt32`. Navigate sequentially to `HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\Exploer`. The subkey `NoDriveTypeAutoRun` restricts the scope of Autorun, with a default value of 95 (hexadecimal).

To disable certain devices, add their flags and set them as the key value. The device flags are as follows:

- 1: Unrecognized devices (it is recommended to disable; default is disabled)

- 2: Devices without a root directory (unknown meaning; it is recommended to disable; default is not disabled)

- 4: Removable devices (USB drives; it is recommended to disable because many viruses use USB Autorun.inf for propagation; default is disabled)

- 8: Fixed devices (hard drives; decide based on your needs; default is not disabled)

- 16: Network devices (web drives; it is recommended to disable; default is disabled)

- 32: CD-ROM drive devices (default is not disabled)

- 64: Virtual storage devices (RAM; it is recommended to disable; default is not disabled)

- 128: Unspecified other drivers (reserved bit; it is recommended to disable; default is disabled)

### 3. Structure of Autorun.inf File

The autorun.inf file is divided into three main sections: `[AutoRun]`, `[AutoRun.Alpha]`, and `[DeviceInstall]`.

- **[AutoRun]**: Applicable to systems above Windows 95 and 32-bit CD-ROMs; mandatory.

- **[AutoRun.Alpha]**: Applicable to RISC-based computer optical drives, suitable for Windows NT 4.0; optional.

- **[DeviceInstall]**: Applicable to systems above Windows XP; optional.

### 4. Commands and Detailed Explanations for [AutoRun]

#### 1. DefaultIcon

- **Meaning**: Specifies the default icon for the application.

- **Format**: `DefaultIcon=icon path name[, index]`

- **Parameters**:

- Icon file name: Path name of the default icon for the application. Formats can include `.ico`, `.bmp`, `.exe`, `.dll`. When the file format is `.exe` or `.dll`, sometimes an index is needed to specify the icon.

- Index: When the file format is `.exe` or `.dll`, the file may contain multiple icons. Use the index to specify which icon to use. Note that the index starts from 0.

- **Remarks**: The default icon for the application will replace the default icon of the device in the display window driven by the core of Windows Explorer.

- **Default Directory**: The default directory for the icon path name is the root directory of the device.

#### 2. Icon

- **Meaning**: Specifies the display icon for the device.

- **Format**: `Icon=icon path name[, index]`

- **Parameters**:

- Icon file name: Path name of the default icon for the application. Formats can include `.ico`, `.bmp`, `.exe`, `.dll`.

- Index: When the file format is `.exe` or `.dll`, the file may contain multiple icons. Use the index to specify which icon to use.

- **Remarks**: The display icon for the device will replace the default icon of the device in the display window driven by the core of Windows Explorer.

- **Default Directory**: The default directory for the icon path name is the root directory of the device.

- **Note**: This command is invalid if there is an application default icon (`DefaultIcon`).

#### 3. Label

- **Meaning**: Specifies the description of the device.

- **Format**: `Label=description`

- **Parameters**:

- Description: Any text, including spaces.

- **Remarks**: The device description will replace the default description/volume label of the device in the display window driven by the core of Windows Explorer. In non-core display windows (e.g., right-clicking the device and selecting properties), the volume label of the device is still displayed.

#### 4. Open

- **Meaning**: Specifies the command line to run when the device is enabled.

- **Format**: `Open=command line`

- **Parameters**:

- Command line: The program path name [parameters]. Must be `.exe`, `.com`, or `.bat` files. Other formats can be opened using `start.exe` or the `ShellExecute` command.

- **Remarks**: The starting directory for the command line is the root directory of the device and the system’s `$Path` environment variable.

#### 5. ShellExecute

- **Meaning**: Specifies the file to execute when the device is enabled. (Operating system support unknown)

- **Format**: `ShellExecute=path to executable file [parameters]`

- **Parameters**:

- Path to executable file: The path name of the file to execute when the device is enabled. Can be any file format. The system will call the set program to execute this file.

- Parameters: Adjust parameters according to the executed file.

- **Remarks**: The starting directory for the command line is the root directory of the device and the system’s `$Path` environment variable.

#### 6. Shell\Keyword\Command

- **Meaning**: Defines the command line for the device's right-click menu.

- **Format**: `Shell\Keyword\Command=command line`

- **Parameters**:

- Command line: The command line to run automatically. Must be `.exe`, `.com`, or `.bat` files. Other formats can be opened using `start.exe`.

- **Remarks**: The starting directory for the command line is the root directory of the device and the system’s `$Path` environment variable.

#### 7. Shell\Keyword

- **Meaning**: Defines the text for the device's right-click menu.

- **Format**: `Shell\Keyword=text`

- **Parameters**:

- Keyword: Used to mark the menu, can be represented by any character, including spaces.

- Text: The text displayed in the right-click menu. Can use any characters but cannot have spaces.

- **Remarks**: In the same Autorun.inf file, different right-click menu keywords must be unique. To define accelerator keys in the right-click menu, use `&`; `&&` outputs one `&`.

- Both `Shell\Keyword\Command` and `Shell\Keyword` are required, order does not matter.

- If neither `Open`, `ShellExecute`, nor `Shell` commands exist, the first command specified in the device's right-click menu will run when the device is enabled.

#### 8. Shell

- **Meaning**: Defines the right-click menu command to run when the device is enabled.

- **Format**: `Shell=keyword`

- **Parameters**:

- Keyword: A marked menu keyword.

- **Remarks**: The keyword specified by Shell can be located anywhere in the Autorun.inf file.

- Priority is higher for definitions after `Open`, `ShellExecute`, or `Shell` commands.

### 4. [AutoRun.alpha] Section Commands

The commands in the `[AutoRun.alpha]` section are the same as those in the `[AutoRun]` section. However, in RISC-based computer optical drives, `[AutoRun.alpha]` has a higher priority than `[AutoRun]`.

### 5. [DeviceInstall] Section Commands and Detailed Explanations

#### DriverPath

- **Meaning**: Defines the search directory for driver programs.

- **Format**: `DriverPath=driver program path`

- **Parameters**:

- Driver program path: The path where the driver program is located, including its subdirectories.

- **Remarks**: Supported by Windows XP and above.

- Only applicable to CD-ROMs.

- When the system detects a new device, it prompts the user to find the device's driver program. If the user selects this CD-ROM and the `[DeviceInstall]` section exists, the system will search for the driver program along the path marked by `DriverPath`. Paths not marked will be ignored. If the `[DeviceInstall]` section does not exist, the system will perform a full search.

- If you do not want the system to search for driver programs on this CD-ROM, simply add a `[DeviceInstall]` line without adding the `DriverPath` command.