Saturday, February 11, 2012

All about 'Autorun.inf'

What is the 'Autorun.inf' file?
The file extension .inf stands for information file. The file is a simple text-based configuration file that tells the operating system (OS) how to deal open the presentation and treat the contents of the media (CD, DVD, USB thumb drive, etc). It tells the operating system which executable to start, which icon to use, and which additional menu commands to make available.
It defines the following:
  • The process or application that will automatically run when a disk is inserted
  • Optionally, one can define the process or application that will run for specific Operating environments.
  • The icon that will represent your application's CD or DVD when the drive is viewed with My Computer or Explorer.
  • Menu commands displayed when the user right-clicks the CD-ROM icon from My Computer or Explorer.
What does it contain?
There are 5 parts to this file: [autorun], [Content], [ExclusiveContentPaths], [IgnoreContentPaths], and [DeviceInstall]

Sections:
  1. [AutoRun]
    1. This section is required for the file to be valid
    2. There can be one of these sections for the different operating systems (e.g. [autorun], [autorun.mips], [autorun.alpha], etc).  This is important so the appropriate executables run that are compatible with the computer the media is entered in.
    3. PURPOSE: contains the default AutoRun commands
    4. VALID KEYS:
      • Action
        • Specifies text to be ussed in the AutoPlay dialog to represent the program specified in the open or shellexecute keys.
        • VALUES: Text or '@[filepath\]filename, -resourceID 
      • Open
        • Specifies the path, file name and optional parameters to the application that AutoRun launches when a user inserts a disc in the drive
        • It is the CreateProcess function that is called by AutoRun.
        • VALUES: '[exepath\]exefile [param1 [param2 ...]]'
      • Icon
        • Name of a file resource containing an icon.  This icon will replace the icon of the drive when it is looked at from
        • VALUES: 'iconfilename[,index]'
        • EXAMPLE:
          • icon=MyProg.exe,1
      • Label
        • This will be the text label of the drive
        • VALUES: Text
        • EXAMPLE:
          • label=My Drive Label
      • shellexecute
        • Like the open command but this uses the machine's association information for the file type.
        • VALUES: '[filepath\]filename [param1 [param2 ...]]'
        • EXAMPLES:
          • shellexecute="Readme.txt"
          • shellexecute=[filepath\]filename[param1, [param2]...]
      • UseAutoPlay
        • Use AutoPlay rather than AutoRun
        • VALUES: boolean
        • EXAMPLE:
          • UseAutoPlay=1
      • shell\verb\command
        • Adds a custom command to the drive's shortcut menu.
        • Verb is a string with no embedded spaces.
        • Verb is also the text that will appear in the shortcut menu unless specifically altered to some other text
        • VALUES: '[exepath\]exefile [param1 [param2 ...]'
        • EXAMPLE:
          • shell\readit\command=notepad abc\readme.txt
            shell\readit=Read &Me
      • shell\verb
        • Optionally specify the text displayed in the shortcut menu for the verb above.
        • Use an ampersand (&) to select a hotkey for the menu.
        • VALUES: Menu Text
        • EXAMPLE:
          • shell\verb\command=Filename.exe
            shell\verb=MenuText
      • shell
        • Defines the menu command referred to by shell\verb as the default command in the shortcut menu.
        • The default command is the command executed when the drive icon is double-clicked.
        • If missing, the default menu item will be "AutoPlay", which launches the application specified by the open entry.
        • VALUES: Text
        • EXAMPLE:
          • shell=verb
  2. [Content]
    1. This section is not required
    2. PURPOSE: Allows authors to communicate the type and intent of content to AutoPlay without AutoPlay having to examine the media
    3. VALID KEYS:
      • MusicFiles
        • Values: boolean
      • PictureFiles
        • Values: boolean
      • VideoFiles
        • Values: boolean
    4. The key values will determine if the handlers associated with that contect type are displayed
    5. EXAMPLES:
      • [Content]
        MusicFiles=Y
        PictureFiles=0
        VideoFiles=false
  3. [ExclusiveContentPaths]
    1. This section is not required
    2. PURPOSE: Limits AutoPlay's content search to only those folders listed, and their subfolders. The folder names are always taken as absolute paths (a path from the root directory of the media) whether or not a leading slash is used.
    3. EXAMPLE:
      • [ExclusiveContentPaths]
        \music
        \music\more music
        music2
  4. [IgnoreContentPaths]
    1. This section is not required
    2. IgnoreContentPaths takes precedence over ExeclusiveContectPaths so if a path given in a [IgnoreContentPaths] section is a subfolder of a path given in an [ExclusiveContentPaths] section it is still ignored.
    3. PURPOSE:AutoPlay's content search system will not scan the folders listed, nor their subfolders.
    4. EXAMPLE:
      • [IgnoreContentPaths]
        \music
        \music\more music
        music2
  5. [DeviceInstall]
    1. Used to indicate where driver files may be located
    2. Not used with AutoRun or AutoPlay and is only referred to during a driver installation phase
    3. Multiple key entries are allowed.
    4. PURPOSE: used to indicate where driver files may be located. 
    5. VALID KEYS:
      1. DrivePath
        1. Values: text (a directory path)
    6. EXAMPLE:
      • [DeviceInstall]
        DriverPath=drivers\video
        DriverPath=drivers\audio
Simple example of an autorun.inf

[autorun]
open=PStart.exe
action=Run PStart Program
icon=PStart.exe
label=My Portable PC


Complex example of an autorun.inf

[autorun]
open=filename.exe /argument1
icon=\foldername\filename.dll,5
[autorun.mips]
open=filenam2.exe
icon=filename.ico
[autorun.alpha]
open=filenam3.exe
icon=filename.ico
[autorun.ppc]
open=filenam4.exe
icon=filename.ico
shell\install = &Install
shell\install\command = setup.exe
shell\uninstall = &UnInstall
shell\uninstall\command = Uninstall.exe
shell\readme = &Read Me
shell\readme\command = notepad readme.txt
shell\help = &Help
shell\help\command = helpfilename.hlp


For more information see these associated blog posts:

No comments:

Post a Comment