Cry How To...


Create a CD that will autorun


To create a CD that will auto-run is actually very simple. All you need to do is to create the file 'AUTORUN.INF' in the CD's root directory and put some simple commands in the file to indicate what you want to be auto-run. The file ‘AUTORUN.INF is a simple text file - so use notepad to edit it.

The 'AUTORUN.INF' file must start with the following line:

[autorun]

It can then include any of the following (optional) commands - with each command placed on a separate line:

icon=icon.ico Specifies the name of the icon file that will be used by explorer as the icon for that CD.

This may be the name of an executable file that contains an icon. If the executable contains more than one icon then an optional index field can be specified to indicate which icon to use:

icon=iconfile,index

label=text label Text label that will be displayed against the CD within explorer.
open=exefile Specifies the command that is to be autorun when the CD is first inserted. It may include a path and any arguments.
shellexecute=datafile Specifies an application or data file that is to be opened. Windows will launch the application associated with that file type to open the datafile.

Note:

  • ShellExecute does not work on older versions of Windows (i.e. under Windows 95 or Window 98 or NT 4).
  • Do not use spaces the filename or it will not work.

For example to create a CD that will autorun the program ‘setup.exe’ would require an AUTORUN.INF file similar to:

[autorun]
open=setup.exe
icon=setup.exe

To create a CD that will autorun to open the html file 'index.htm' would require:

[autorun]
shellexecute=index.htm
icon=index.htm

However, since some older versions of Windows do not support 'ShellExecute' a less elegant alternative would be:

[autorun]
open=command /c start index.htm
icon=index.htm

Be aware that the use of 'command' and 'start' restrict this to machines running Windows.


Related how-to notes:


These notes are believed to apply to all versions of Windows.



About the author: is a dedicated software developer and webmaster. For his day job he develops websites and desktop applications as well as providing IT services. He moonlights as a technical author and consultant.