Introduction
When a data CD, DVD or USB device is inserted into a Windows computer, AutoPlay
decides what to do:
- Usually: shows a dialog box of options to the user - see example on right
- Or: runs the "AutoRun" program immediately
A CD, DVD or USB-memory-device can have an AutoRun file (in plain text calledAUTORUN.INF
in its root folder).
Windows follows the instructions in this AutoRun file to start a program,
eg to run ShellRun to show the CD content.
The AutoRun instructions are also used in "My Computer" to set the drive icon, label and AutoPlay,
ie what happens when you double-click on the drive.
It is important to remember that AutoPlay/AutoRun can be disabled, so you must provide
instructions for starting your CD/DVD/USB 'by hand'.
Note: In all the example screen shots given here, the text "Start ShellRun-CD", "ShellRun-powered CD" etc can
be customised to your own values by altering the AutoRun file.Windows XP, Vista and 7 differences
Windows XP, Windows Vista and Windows 7 each behave slightly differently by default for
CD/DVD and USB memory sticks.
Each user can also configure or disable AutoPlay in their Control Panel.
The folloiwng options assume that a suitableAUTORUN.INF
file is in the root of the
CD, DVD or USB-memory-stick.
AutoPlay CD/DVD
- In Windows XP, a CD/DVD will typically run the AutoRun program automatically.
- In Windows Vista and Windows 7, a CD/DVD will usually open the AutoPlay options window, as shown above right.
- In some situations, AutoPlay will be switched off - you must open the CD/DVD folder and double-click on
a file to show some content.
AutoPlay USB
- In Windows XP and Windows Vista, when you insert a USB memory stick, the AutoPlay dialog,
is normally shown - see example on the right.- In Windows 7, the AutoPlay window does not normally list the AutoRun option,
so you must open the folder and double-click on a file:
My Computer
If you open My Computer, the CD, DVD or USB device will show a suitable icon and label.
For CDs/DVDs, either double-click on the drive - or right-click to show a menu of options, eg with "Start ShellRun-CD" as shown on the right.
For USB devices, click on "Open AutoPlay..." or "Explore" the folder and run a file on the disk if necessary.
Simple AutoRun example
If Windows finds a (plain text) file calledAUTORUN.INF
in the root directory of a CD
then it follows the instructions in this file to run a program, as per the above descriptions.
This example
AUTORUN.INF
file tells Windows to run program
shellrun.exe
(from the root directory of the CD) which in turn will show web page
default.htm
in the user's default browser. The other options are described below.
[autorun]
open=shellrun.exe default.htm
icon=shellrun.exe
action=Start ShellRun-CD
label=ShellRun-powered CD
Use the Windows Notepad application to edit plain text files
(it is in the Start+All Programs+Accessories menu).
Your CD users may have switched off AutoRun. This might be because they are concerned
about viruses. Also, if they press the Shift key down while inserting the CD,
AutoRun is disabled.
There is no way to force your users to use AutoRun. It is therefore good practice to provide
instructions so that users know how to start your CD, eg tell them to open file
default.htm
in their browser. These instructions are also required if your CD
might be viewed by non-Windows users.
So why is ShellRun needed?
To be honest, you do not really need ShellRun. All recent Windows computers let you show a file
as well as run a program, eg:
[autorun]<br />shellexecute=index.htm
If you use ShellRun instead, then a small window appears quickly to let the user know
that something is happening. The freeware version of ShellRun looks like the screen shot on the right.
If you wish to customise the display, provide a menu etc, then please look at the
retail version.
What does ShellRun do then?
ShellRun shows your file and displays a neat popup window.
The popup appears straight away so that the user knows that something is happening.
ShellRun works in all Windows systems.
This exampleAUTORUN.INF
tells ShellRun to show web pageindex.htm
while displaying message "Starting CD now..." in the ShellRun popup window.
[autorun]<br />open=ShellRun.exe index.htm Starting CD now...
Do not forget to putShellRun.exe
in the root directory of your CD along with
AUTORUN.INF
.
Viewer Technicalities
All the above AutoRun examples, including ShellRun, use the same core technique to display
a file.
Windows associates a viewer program with each file type. For .HTM and .HTML
web pages, the viewer program will be your default browser.
If a user does not have a viewer for your file type then it cannot be displayed
until a viewer is installed. For example, if you are trying to show a PDF file,
the user must have Adobe™ Reader or equivalent installed.
If a viewer is not available, the freeware version of ShellRun just displays a message.
In retail version you can prompt the user to run a viewer installation program.
See the Viewers page for more details.
If you have a viewer program available then put its installation program
on your CD - if you are allowed to distribute it.
To distribute Adobe™ Reader, see here:
Adobe Reader - Download Adobe Reader for distribution.
Enabling AutoRun on your computer
Feb 24, 2009: This Microsoft KB 967715 article
has the latest information on AutoRun - see the More Information section
.
To test AutoRun you need to have it enabled on your computer. A registry setting
can be used to disable AutoRun. Click Start+Run then type in regedit.
Select Edit+Find and type in NoDriveTypeAutoRun. This value should
be found in this key:
HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer
.
The NoDriveTypeAutoRun value should be hexadecimal 95 if AutoRun is enabled on all CDs,
or B5 if disabled for CDs. (If you want to test AutoRun on a floppy disk,
set this value to 91.)
You may need to change more than one instance of NoDriveTypeAutoRun in the registry.
You usually need to reboot for a new value to take effect.
In Windows 95/98/Me the NoDriveTypeAutoRun value is displayed as
95 00 00 00
. In Windows NT4, 2000 and XP this value is
displayed as0x00000095
or hexadecimal95
. If you modify the NoDriveTypeAutoRun value
make sure it is still in the correct format.
More ways to disable AutoRun
There are two other - uncommon - ways of disabling AutoRun. The NoDriveAutoRun registry
value is in the same key as NoDriveTypeAutoRun. Each bit represents each drive, so
hexadecimal 01 disables AutoRun for floppy drive A, 04 disables AutoRun
for drive C, 10 disables AutoRun on E. Values can be combined, so 19
disables AutoRun on E, D and A.
If either NoDriveTypeAutoRun or NoDriveAutoRun specify that AutoRun should be
disabled for a drive, then it is disabled for that drive.
Finally, programmers might like to know that AutoRun can also be disabled by the
program that controls the foreground window by handling the "QueryCancelAutoPlay"
Windows message. Please consult the Microsoft documentation for more details.
More AutoRun options
You can set further options in theAUTORUN.INF
file.
- You can provide an icon for the CD drive in My Computer by adding a line
that set theicon
command to an .ICO file or an .EXE that contains an icon.
- You can set a text label for the drive using the
label
command and the text that
appears in the AutoPlay dialog using theaction
command.
For example:
[autorun]<br />open=ShellRun.exe report.mpg Showing video now...<br />icon=shellrun.exe<br />action=Start ShellRun-CD<br />label=ShellRun-powered CD
- Use a series of
shell
commands
to specify one or more entries in the pop-up menu
that appears when the user right-clicks on the CD icon.
(Theshell
entries supplement the open command.)
This example shows how to add two entries to the menu
(Read me - to display the README.TXT file in Notepad, and
Software list - to show HTML file software.htm):
[autorun]<br />...<br />shell\readme\command=notepad README.TXT<br />shell\readme=Read &me<br />shell\software\command=ShellRun.exe software.htm<br />shell\software=Software list
Any verb string (without spaces) can appear after "shell\";
"readme" and "software" were used above.
On one line, append "\command=" followed by the command you want to run.
On the next line, append "=" and the text that appears in the menu.
Put an ampersand character (&) before the character that should be used as the menu item short-cut key.
- Windows XP also supports a [DeviceInstall] section in
AUTORUN.INF
with theDriverPath
command specifying a base directory for driver file searches.
AUTORUN.INF
may have other sections for other NT/W2000 users,
ie MIPS [autorun.mips], DEC Alpha [autorun.alpha] and PowerPC [autorun.ppc].
Enhanced CDs - music and data
Enhanced CDs contain both music audio and computer data, so they can be played on
audio equipment and used on a computer. (Enhanced CDs are also known as
CD Extra or CD Plus CDs.) Note that the Mixed-mode CDs also
contain audio and data, but these may not be playable on audio equipment.
Note that not all Windows computers will recognise the data on an Enhanced CD,
although the audio is always seen.
(Windows Me, 2000 and XP usually seem to recognise Enhanced CD data, but it may
be drive dependent.)
A test Apple Mac (iMac OS 10.2.8) did recognise the audio and data;
however a Mac with OS 9 did not.
If the Enhanced CD data does not have an AUTORUN.INF file, then Windows will usually
start playing the CD when it is inserted.
However, if an AUTORUN.INF is present, then Windows will follow the instructions in there
rather than playing the CD. The retail version of ShellRun has an option
to start playing the audio - see here for details.
The data on an Enhanced CD can only use short filenames or folder names.
Long filenames will be truncated to an "8.3" form, eg "index.html" may appear as "INDEX~1.HTM".
AutoStart on Macs
The equivalent to AutoRun on Macs is called AutoStart.
We are informed that this only works on OS9 and earlier;
Mac OS10 via Toast
only allows you to open a folder window and not an application.
MacImage for Windows says that
it can create AutoStart CDs on a PC.
Other tools:
Toast for Mac.
CDEveryWhere.
We have not tested any of these products.
Keiser Photography
have instructions for using Toast to make a CD that will AutoStart on a Mac as
well as using ShellRun to AutoRun on Windows computers.
Filenames as seen by a Mac
By default, CDs created on a PC might have garbled filenames when viewed on an old Mac.
Long filenames will be truncated to an "8.3" form, eg "index.html" may appear as "INDEX~1.HTM"
on a Mac.
However OS X 10.2.6+ recognises long file names.
However, a pre OS-X Mac user can install the shareware Joliet File System Extension, from
http://www.tempel.org/joliet/, which will
make long PC filenames readable. If your CD uses the Joliet format because it has long filenames,
then suggest to your
Mac users that they install this software to view the CD fully.
Therefore, if you have Mac users, it is best to ensure that your filenames are short, and provide
instructions for viewing the CD manually, eg "View this CD by opening INDEX.HTM in your browser".
REFERENCES
http://www.phdcc.com/shellrun/autorun.htm