DevCity.NET - http://devcity.net
Creating AutoRun Media to deploy your application.
http://devcity.net/Articles/322/1/article.aspx
Arnaldo Sandoval
I began my run in the IT field back in 1975 while at the University getting my Industrial Engineer Bachelor Degree; using Wang Basic language and Burroughs 6700's FORTRAN and COBOL, working as a Teacher’s assistance for a fist full of dollars, since then I had worked in four different countries: Venezuela, USA, Mexico and Australia, the Business Basic Language the main skill expected from me; learning Unix, C, PASCAL, Uniplex, WordPerfect, 20/20 in the lates 80s, Sybase in the early 90s, Basis BBx in the 90s, Microsoft’s VBA in the mid 90s, Visual Basic version 3.0 around 1996; moved to Australia in the lates 90s, here I kept learning, Transoft’s Universal Business Language, Oracle, Microsoft SQL Server, Visual Basic .Net; working for a major Australian company in the building material market. I had worked for Computers Manufacturing companies (MAI Basic Four after reading the Wikepedia definition, it feels good being an active part of the industry), and high rollers companies (DOLE, Pepsico when they operated Pizza Hut, KFC, Taco Bell and PFS, Boral Limited), roaming the world while doing so, exposed to cutting edge technologies of their time, creating it when the opportunity required so. I currently look after an Oracle data warehouse, sourcing its data from four or five legacy applications, servicing Crystal Reports and Cognos Cubes, developed VB and Net solutions; I could claim the phrase “I had been there, done that” suits me like a globe, always addressing any challenge with an engineer mind, which is different to an IT mindset.  
by Arnaldo Sandoval
Published on 8/3/2007
 

A challenge we all face after finalizing an application is its distribution.  There are so many options available to us nowadays.

 One of them is by burning a distribution media, which could either be a CD or DVD (perhaps, even a USB drive). Your aim should be that once the user inserts your distribution media the installation process starts automatically or greet the user with a professional looking web page.

This article will take your through the steps required to create your distribution media to autorun as soon as the user inserts it into the workstation drive.


Page 1
SCOPE

The procedure described by this document explains how to create a CD Rom to distribute your .Net Application, carrying the .Net Framework and executing its installation upon inserting of the media into the Target Machine CD-Drive.

This document does not apply to VS 2005 Click Once Deployments.

TERMINOLOGY
  • Target Machine is the PC or workstation your project will be installed on.
  • Installation Package is the MSI file you generated using the Deployment and Installation module in your VS.Net 2002, 2003 or 2005 for either C# or Vb.Net
  • Net Framework Redistributable is the net framework required by your application, it could be the 1.0, 1.1 or 2.0
  • MEDIA a CD or DVD disc that will contain your application's installation package.

REQUIREMENTS

APPLIES TO

  • Any version of Windows, although, We know we can't install .Net application on any Windows Version prior to Windows 98 SE.
  • Visual Studio 2002, 2003 or 2005, C# or Vb.Net

AUTORUN CD OVERVIEW

Autorun CDs or DVDs are unrelated to the Visual Studio's SetUp and Deployment Projects, you should organize the media in order to get your application's installation package running once the enduser insert it at his/her machine's media drive.

HOW TO ORGANIZE THE CD or DVD

You don't burn a MEDIA, either CD or DVD directly when creating your application's installation package, what you do is create a temporary folder that will store all the information your MEDIA will contain.

We suggest the name CD_IMAGE, the image below is a sample CD_Image folder for an application being distributed by a CD or DVD media.

 

The image shows that for this particular application, we are including Microsoft, Macromedia and LotusNotes applications or objects, as we can gather from the folders identifying these companies. You should also keep in mind to include the proper disclaimer and references to copyrighted information you are distributing with your application.

Your application installation package or the autorun script should take care of using the information in your distribution MEDIA, they will not install automatically, some logic should execute them.

You should also notice the autorun.inf file highlighted in the image, that's the key file to create an AUTORUN MEDIA.

The complexity of your CD_IMAGE folder depend on the complexity of your application, it may contains just the Microsoft folder because you are including the .Net Framework distributable, it may also contains a Web Site because you want to drive your application installation with one.

 

 

Page 2
THE AUTORUN.INF FILE

The key task is to create an AUTORUN MEDIA, because without it, your application's deployment project will not run automatically; this file is very simple, as you can see below:

Code:

[autorun]
shellexecute=Princeton_Install.exe


It has one section autorun enclosed between square brackets, and this section contains one single line: shellexecute followed by the name of an executable .exe file.

The sampe code shown match the image above, notice that the Princeton_Install.exe is also in the picture. We will explain more about what name to use later on.

This autorun.inf file executes the program on its shellexecute line, although, it will not start a web application to drive your user during the installation process, more about that later on as well.

THE shellexecute= COMMAND LINE

This is the line that idenfities the file to run when the user insert your CD MEDIA into the MEDIA Drive, the code snippets shows the name Princeton_Install.exe; You should use a different name of course.

Your Visual Studio's Setup and Deployment Project will generate three files at its Release folder, they will be an exe, msi and ini files, all three should have the same basename, if you want to name them MyApplication you will have:

Code:

MyApplication.Exe
MyApplication.MSI
MyApplication.Ini


Those three files should be copied to your CD_IMAGE folder and you should use the EXE file in the shellexecute= line, like this:

Code:

shellexecute=MyApplication.Exe


The whole autorun.inf file will look like this:

Code:

[autorun]
shellexecute=MyApplication.Exe
 
 

That will be it, the AutoRun.inf file now contains the name of the executable file to run once your application's distribution MEDIA is inserted into the MEDIA drive on the target machine by the user installing your application. You should keep in mind, we are talking about the CD_Image folder, you should build the MEDIA in order to test everything we had explained so far in this document, although, you should wait and keep reading, as there are more items you should add to the CD_Image folder.

You may want to look at the references below, some of the articles explains fancy thing you can do with autorun.inf files.

THE MICROSOFT FOLDER

Let's talk about the Microsoft folder appearing on the image above, your .Net application distribution media should include the corresponding .Net Framework redistributable installer, plus, depending on its design, additional Microsoft installers could be included in this folder, like the Microsoft Data Access Component (MDAC) and many more, like the IE6_Setup (It was a requirement to support Windows 98 SE for the application used to illustrate this article, some Windows 98 SE environment may not have IE6 installed, you need IE6 to install run .Net applications). 

 

Now, the autorun.inf file is completley unaware of the Microsoft folder, it is part of the distribution MEDIA because your application's installation package requires it; We already know that a Launch Condition directs the installation process to run the Net Framework distributable code, or a Custom Action module may run the MDAC or anything else located on the MEDIA.

You should copy the .Net Framework redistributable file under the CD_Image\Microsoft folder, if you created the launch condition as described by the FAQ document referenced above.

BURNING YOUR DISTRIBUTION MEDIA

Once you prepared the CD_IMAGE folder with all the files required by your .Net Application's installation, you are ready to burn its distribution MEDIA; (this document explains few things your distribution MEDIA may contain, there is not limit, it will be upto its requirements what to include on the MEDIA). The final step is to run your favourite MEDIA burner application (Nero or something else) copying everything under your CD_Image folder; WARNING Your MEDIA should include everything after the CD_Image folder, this folder itself should not be part of the MEDIA.

SUMMARY

This summary is a step by step procedure to create a distribution MEDIA including the .Net Framework redistributable for your .Net Application.

  1. Create a folder named CD_Image anywhere on your hard drive.
  2. Create a folder named Microsoft under the CD_Image folder created on the previous step (CD_Image\Microsoft).
  3. Download the .Net Framework re-distributable file from Microsoft.
  4. Copy the .Net Framework re-distributable file just downloaded to the CD_Image\Microsoft folder.
  5. Create the .Net Framework's launch condition on your Visual Studio's Setup and Deployment Project. You can't if you are using VS 2002.
  6. Make sure your .Net Framework's launch condition's property InstallURL is referencing the folder-file Microsoft\DotNetFx.Exe
  7. Build your application Deployment Project, make sure you are building a Release version.
  8. Copy the three files (exe, ini and msi) under your deployment project's release folder to the CD_Image folder.
  9. Make sure all three files share the same name, like:

    Code:

    MyApplication.Exe
    MyApplication.Ini
    MyApplication.Msi


  10. Create using your favourtie editor the autorun.inf files under the CD_Image folder, the autorun.inf file should contains at least these lines:

    Code:

    [autorun]
    shellexecute=MyApplication.Exe



  11. Copy any additional file(s) required by your application installation process, or your application documentation to the CD_Image, in other words, you can include anything you want to distribute with your application's distribution MEDIA.
  12. Run your favourite MEDIA burner (Nero or something else)
  13. Make sure the MEDIA your are burning contains all the information underneath the CD_Image folder. You should not create the folder CD_Image on the MEDIA.
  14. You should test your application distribution MEDIA on any machine or Virtual PC.
  15. Congratulations, you successfully created a distribution MEDIA for your application. 
     
 

Page 3

AUTORUN A WEB PAGE-SITE AFTER INSERTING YOUR DISTRIBUTION MEDIA ON THE TARGET MACHINE:

You may take this section as an additional alternative when designing your distribution media, currently the autorun.inf does not allow you to start a Web Application easily when you insert your CD or DVD media, but there is a freeware program known as ShellRun.exe written by PHD Computers Consultants that will allow you to do just that, this freeware program should be shipped in your media, and it will handle any web page request on the target machine, if you are shipping a web page-site in your distribution media, you should be able to make your distribution media installation interface experience more user friendly to your customers, by driving them through out a web page.

You can find more information about ShellRun.exe at this web site
PHD Computer Consultants Ltd (ShellRun.exe); We suggest you to visit their web site as it contains further information about the autorun.inf file required to create autorun media.

The ShellRun.Exe does not replaced the autorun.inf file at all, you reference this program within the autoron.inf

If you decide to distribute your application with an autorun media showing a Web Site/Page, you should develop it using plain HTML pages (unless your web page development skills are solid); All the pages and images shown by this web installation site/page should be included as part of your distribution media, this is a folder containing all the files required, you may named this folder with something like MyInstallationPage or whatever suit you better.

If you take this path to distribute your application, your autorun.inf file should be something like the one show below:

Code:


[autorun]
open=shellrun.exe MyInstallationPage\index.html
icon=btw.ico


Where:


  • shellrun.exe is the program downloard from the PHD Computer Consultants page.
  • MyInstallationPage is a folder on your distribution media containing the installation page web files.
  • index.html is your installation site's home page, this file is located on your distribution media under the MyInstallationPage folder.
  • icon= is an autorun.inf token identifying the icon to be displayed when looking at your CD-DVD media using Windows Explorer.
  • btw.ico is the icon file, located on your CD-DVD distribution media's root directory. You can use whatever icon suits better your needs.

You should create the folder MyInstallationPage, and include the files shellrun.exe, btw.ico (or whateve icon suits you better) and index.html under your CD_IMAGE folder described above.