This step-by-step article describes how to create Autorun-enabled CD-ROMs for Microsoft Visual Studio .NET applications. Autorun is a feature of the Microsoft Windows operating system. It automates the procedures for installing and configuring products that are designed for Windows-based computers and are distributed on CD-ROMs. When a user inserts an Autorun-enabled CD-ROM in the CD-ROM drive, Autorun automatically runs an application on the CD-ROM that installs, configures, or runs the selected product. To create an Autorun-enabled CD-ROM for your Visual Studio .NET application, the following files must exist on the CD-ROM:
back to the top
- An Autorun.inf file
- Startup application
back to the top
- The operating system of the computer must be Microsoft Windows 95 or later.
- The CD-ROM drive must have 32-bit device drivers that detect when a user inserts a CD-ROM, and then notify the system.
- The name of a file that contains an icon that represents your application's CD-ROM drive. This icon appears in Windows Explorer instead of the standard drive icon.
- Additional commands for the shortcut menu that appears when the user right-clicks the CD-ROM icon. You can also specify the default command that runs when the user double-clicks the icon.
- The [autorun] section contains the default Autorun commands. All Autorun.inf files must have an [autorun] section.
- An optional [autorun.alpha] section can be included for Microsoft Windows NT 4.0 systems running on RISC-based computers. When a CD-ROM is inserted in a CD-ROM drive on a RISC-based system, the Windows Shell runs the commands in this section instead of those in the [autorun] section.
- defaulticon: Specifies the default icon for the application.
- icon: Specifies the path and the file name of an application-specific icon for the CD-ROM drive.
- open: Specifies the path and the file name of the startup application.
- shell: Defines the default command in the shortcut menu of the CD-ROM.
- shell\verb: Adds commands to the shortcut menu of the CD-ROM.
back to the top
- Users should receive feedback as soon as possible after they insert an Autorun CD-ROM in the CD-ROM drive. Therefore, startup applications should be small programs that load quickly. They should clearly identify the application and provide an easy way to cancel the operation.
- Typically, the initial part of the startup application presents users with a user interface (such as a dialog box) that prompts them for how they would like to proceed. Verify whether the program is already installed. If not, the next step is typically the setup procedure. The startup application can use the time that the user spends reading the dialog box to start another thread to start loading the setup code. When the user clicks OK, your setup program will already be partly or fully loaded. This approach significantly reduces the user's perception of the time that it takes to load your application.
- If the application is already installed, the user probably inserted the disk to run the application. As with the setup case, you can start another thread to start loading the application code. This approach shortens the waiting time for the user.
- The .NET Framework or the .NET Framework Redistributable Package must be installed on the destination computer to start your Visual Studio .NET application. Therefore, it is a good idea to redistribute the .NET Framework with your startup application.
For additional information about how to distribute the .NET Framework with a Visual Studio .NET application, click the following article number to view the article in the Microsoft Knowledge Base:324733 HOW TO: Distribute the .NET Framework with a Visual Studio .NET Deployment Project
- Hard disk space may be a limited resource on many systems. The following are hints to minimize hard disk usage:
- Keep the number of files that must be on the hard disk to a minimum. Restrict these to files that must be installed to run the program or that take an unacceptably long time to read from the CD-ROM.
- In many cases, you do not have to install nonessential files on the hard disk. However, this approach may provide benefits such as increased performance. Give the user the option to decide between the costs and the benefits of hard disk storage.
- Include a method to remove any components that were put on the hard disk.
- If your application caches data, give the user some control over it. Include options in the startup application such as the option to set a limit on the maximum amount of cached data that will be stored on the hard disk, or the option to have the application discard any cached data when it quits.
- Start Visual Studio .NET.
- Create a simple Console Application or Windows Application.
- Build the application.
- On the File menu, point to
New, and then click Project.
Project Types, click Setup and Deployment Projects. In Templates, click Setup Projects.
- Name the project Setup, and then click
- In Solution Explorer, right-click your Setup project, click Add, and then click
- In the File name text box, type the absolute path of the executable that you built in step3, and then click
- On the Build menu, click Build Solution.
- Start any text editor (such as Notepad).
- Paste the following code in the text editor, and then save the file as Autorun.inf:
- To prepare an Autorun CD-ROM for the Visual Studio .NET application that you built in step 3, copy the files that were generated in step 9 and the Autorun.inf file that you created in step 11 to the CD-ROM.
Article ID: 818804 - Last Review: Mar 29, 2017 - Revision: 4