How to create an autorun CD

[This article refers to the Autorun feature of Windows PCs only]

First off, how does the computer know to automatically start the cd?

The computer looks for a file called 'autorun.inf' in the root directory of a CD or DVD as it is inserted into the drive.

What is this autorun.inf file?
It’s a text file containing a few simple computer readable instructions, and can be created with a text editor such as Notepad. This file MUST be placed in the root directory of the disc and MUST be called autorun.inf, otherwise the disc will not auto-start properly. The first line is always '[autorun]' and each command begins on a new line underneath, for example:

Sample autorun.inf text file
Sample autorun.inf text file

The 3 most common commands are 'open', 'icon' and 'label', and while others are available they are more complex and less frequently used.

So how do I auto-start my program?
If you want to automatically start an executable file (e.g. a Flash projector presentation), place your EXE file in the root directory and create an autorun.inf file with the following lines:

[autorun]
open=myprogram.exe


If you want to auto-start a program located somewhere else on the CD (eg. in a sub-folder called TestFolder) then adjust the path to the program in the autorun.inf text file, as below:

[autorun]
open=TestFolder\myprogram.exe


But I want to autorun a Word document I’ve created
The main problem with the autorun function is that only programs (e.g. Word) can be started automatically but not the data files (e.g. your Word document). However, there is a way around this limitation by using a small utility program to act as an intermediary between the autorun.inf file and the data file you wish to auto-start.

So how do I auto-start an html, pdf, doc or other file type?
As long as the file type you wish to run is associated with a program already installed on your machine (e.g. DOC files are usually associated with Microsoft Word) you can use a ‘launcher’ type utility such as the excellent ShelExec.exe autorun by Naughter Software.

To use it, put the ShelExec.exe file and your data file (e.g. mydatafile.pdf) into the root directory of the CD and put the following text into the autorun.inf file:

[autorun]
open=ShelExec.exe mydatafile.pdf


In this example, when the CD is inserted, the program associated with PDF files (usually Adobe Acrobat Reader) will start automatically and open mydatafile.pdf document inside it. To make things a little neater on the CD, and to keep the root directory as clear as possible, you can put the ShelExec.exe file into a subfolder (called Launch, for example), and by updating the path the autorun.inf file would look like this:

[autorun]
open=Launch\ShelExec.exe mydatafile.pdf


What about the other common commands 'icon' and 'label'?
These two commands allow you to change the default CD icon and the electronic volume label you see when navigating your computer using Explorer. By changing the icon and specifying your own disc volume label it gives the disc a more professional feel.

To begin with you'll need an icon file, you could... Next you'll need the text which will become the CD volume label, and for this you can use up to 32 characters. So the following autorun.inf file...

[autorun]
open=Launch\ShelExec.exe mydatafile.pdf
icon=smileyface.ico
label=My favourite photographs


...would open a PDF document called mydatafile.pdf within Adobe Acrobat Reader and the CD would appear visually within Explorer as below:

Result of autorun.inf with 'icon' and 'label' commands
Result in Explorer of using 'icon' and 'label' commands in the autorun.inf file

Advanced autorun commands
Other commands are available but are too advanced to feature here, however the Microsoft Developer Network Autorun.inf page discusses them in more detail.

May 2008