Creating an Autorun CD


As a Windows user you'll undoubtably have noticed that when you drop most CDs in your CD-ROM drive that it automatically starts to run something, usually an installation program. This can be both a blessing and a curse, if you dislike this function then stop reading this tip and go see my Disabling CD Autorun tip. For those of you still with me that have a CD burner, you can make your own homemade CDs autorun as well. You just need an autorun.inf file in the root of the CD.

Autorun.inf File

The autorun.inf file is a simple text file with a fancy extension. The only tool you need to make one is a lousy old text editor like notepad (of course, you would have to rename the file to change the extension from .txt to .inf).

So what's in the file anyway? A series of commands specifying how the whole operation is supposed to work. As it turns out, every command is optional, but if you don't specify anything then your CD won't do anything either. Your autorun.inf file should look like:


I'm sure you'd like to know what sort of commands you can use, so without further confusion, here they are:


The icon command specifies an icon to represent the Autorun enabled drive (i.e. CD-Drive).


The name of an .ico, .bmp, .exe or .dll file that contains the icon to be used. This file must be located in the same folder as the file specified in the open command. If a file contains more than one icon, the icon number must be specified by using the zero based index (icon=myfile.exe,1 for the 2nd icon in myfile.exe).


The label command specifies a label to represent the Autorun enabled drive in the Windows interface. In other words, instead of saying Compact Disc (X:) in explorer it will say label (X:). This supercedes any volume label you may write to your CD.


Any text you like, it can include spaces as well. You should keep it less than 20 characters or so I would say, though I don't know of a limit.


The open command specifies the path, filename and any parameters to the application that will run when the user inserts the disc in the drive.

open=[exepath\]exefile [param1] [param2] ...

Optional, you'll want to specify it if the application is not in the root of the CD. (Technically you don't need to specify it for any programs that would be found in the PATH environment, but that can vary from PC to PC. You also shouldn't rely upon the computer to supply the application, it should be on the CD.)
The application to be run, also include any optional parameters you'll need. NOTE: if the folders or filename contain spaces then enclose the path and filename in double quotes (open="x:\my folder\my program.exe").


The shellexecute command is an alternative to the open command. Do not include both commands in your autorun.inf file, I don't know which will take precedence. Rather than specify an application to execute, you can specify any file and Windows will use that file's associated application to open it. Handy if you'd like to open an HTML index file (shellexecute=index.html will bring up index.html in the user's internet browser).


Again, the full path to the file. Necessary if the file is not in the root of the CD.
Rather self explanatory don't you think? If the file is executable then it will be launched, otherwise the associated application to the filetype will be launched. (The filetype must have an association) Recall again that if there are spaces in either the path or filename that you should include the entire thing in double quotes.


The shell command specifies a default command for the drive's context menu. The context menu is that menu that comes up when you right-click on the drive. If you don't specify anything here, the typical default will be open.


The verb that corresponds to the command. The verb and its associated command must be specified in the autorun.inf file with a shell\verb command.


The shell\verb command adds a custom command to the drive's context menu. You can add as many of these as you like.


The command's verb. This is just a name to refer to your command within the autorun.inf file. If you don't specify the MenuText option, then by default the verb is the text displayed on the context menu.
The path and filename that performs the command, this is just like the open command in its functionality. Supppose you had a readme.txt file that you wanted a command to view, you could use the following shell\Readme\command=notepad.exe readme.txt
This specifies the text that is displayed in the context menu. If it is omitted, then verb is used. The text can be mixed case and may contain spaces. If you want to specify a shortcut key for the item then place an & in the name in front of the letter. (shell\Readme=&Read Description would allow you to press r to run the command once the context menu is displayed.)


label=Xany's Utilities
shell\Readme\command=notepad.exe readme.txt
shell\Readme=&Read Description

The above example will use the icon.ico file for the icon of the drive. The drive will be labelled "Xany's Utilities" in Windows. When you place the CD in the drive, Windows will use the user's web browser to open the index.html file in the html folder of the CD. A default context command, Read Description, has been created that will open the readme.txt file on the CD with notepad. The command has a hotkey of 'R' associated with it.

Additional Remarks

Once you've created your text file, added whatever combination of the above commands you like, and saved the file, make sure you have named the file autorun.inf and have placed it in the root folder (not a folder named root, but the base level folder that contains everything on your disc) of your CD project.

This tip not only works for CDs, but any removable media that supports autoplay features.

If you aren't too comfortable editing the text file yourself, or are just lazy, you could have a look at Autorun Designer which is a freeware program.

Of course, you don't want to make an autorun.inf file, burn your CD and discover it doesn't work. In my forthcoming tip Testing Autorun.inf, I'll describe how you can test your file without potentially wasting a CD.