HOW TO: Create an Autorun CD-ROM for Applications That You Create by Using Microsoft Visual Studio .NET
This article has been archived. It is offered "as is" and will no longer be updated.
IN THIS TASK
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:
- An Autorun.inf file
- Startup application
back to the top
RequirementsThe destination computer must meet the following requirements for Autorun to work:
- 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.
Create an Autorun.inf FileAutorun.inf is a text file that is located in the root folder of your application CD-ROM. It provides to the computer the name and the location of the startup program for your application that is installed when the CD-ROM is inserted. The Autorun.inf file can also contain optional information including the following:
- 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
[autorun] open=Filename.exe icon=Filename.ico
Tips for Writing Autorun Startup ApplicationsEssentially, there are no constraints on how to write an Autorun startup application. You can implement it to do whatever you require to install, remove, configure, or run your application. However, the following tips provide some guidelines for implementing an effective Autorun startup application:
- 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.
- In Project Types, click Setup and Deployment Projects. In Templates, click Setup Projects.
- Name the project Setup, and then click OK.
- In Solution Explorer, right-click your Setup project, click Add, and then click File.
- In the File name text box, type the absolute path of the executable that you built in step3, and then click Open.
- 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.
For additional information, click the following article numbers to view the articles in the Microsoft Knowledge Base:
172078 HOWTO: Enable Autorun for Applications Distributed on CD- ROM
136214 How to Test Autorun.inf Files
back to the top
Article ID: 818804 - Last Review: 12/08/2015 02:34:06 - Revision: 2.2
Microsoft Visual Studio .NET 2003 Professional Edition, Microsoft Visual Studio .NET 2003 Enterprise Architect, Microsoft Visual Studio .NET 2003 Enterprise Developer, Microsoft Visual Studio .NET 2003 Academic Edition, Microsoft Visual Studio .NET 2002 Professional Edition, Microsoft Visual Studio .NET 2002 Enterprise Architect, Microsoft Visual Studio .NET 2002 Enterprise Developer, Microsoft Visual Studio .NET 2002 Academic Edition
- kbnosurvey kbarchive kbredistribution kbhowtomaster KB818804