Run, disc, run

Autorun CDs and DVDs can be a great way to distribute photographs, business presentations, videos and all sorts of other files. All your audience needs to do is pop the disc into a PC and the information magically appears. Judging by the number of questions I receive on this topic, it's clear that most people find the creation of autoruns to be a frustrating affair. However, you may be surprised to learn that all you need is a couple of lines of simple code and an understanding of a few autorun "rules".

There are several different approaches to creating an autorun and some professional-level software packages can set you back $1000 or more. But you can save your money for something more interesting, as this month I'll be showing you how to do it for free, using the humblest of tools - Windows Notepad.

The catch

I can guarantee that when most people try to create an autorun to open an image or HTML file they find it doesn't work. This isn't surprising since there's an extremely important, but far from obvious, catch: an auto­run must start a program, it can't be used to directly open a data file. Try instructing an autorun.inf file to open a JPEG if you don't believe me.

The way you get around this problem involves two stages. First, you instruct the autorun to open a program, then that program, in turn, opens the data file such as a HTML document, Word file, and so on. OK, by now you're probably saying "I can't write a program", so here's the other secret to creating your own autorun - it's actually surprisingly easy. All you need to do is create something called a batch or .BAT file. But before we get started, it's important to understand what you want to happen when the CD is inserted.

Choosing your file

We can get a batch file to open anything, but I'd advise using the file type widely used on the Web - HTML. This format is the best choice because it's the most commonly available and flexible. Not every PC has the software needed to open a Word file or PowerPoint presentation, but most have a Web browser (and Web browsers can view HTML files). You can write instructions in the HTML to tell the end-user what to do, install software if needed, browse content, download files and more. For example, you could give simple instructions that tell users to open a PDF file or install Acrobat reader if they don't yet have it. The only downside is that you'll need to learn basic HTML to do it (or use a WYSIWYG HTML editor).

If you're sending someone a slideshow, this can also be made with HTML. Many graphics programs will export images and create the HTML code needed to view thumbnails and larger versions of the image. For these reasons, this article will only refer to opening a HTML file called index.html, but if you want to try something else, simply replace index.html with the file name.

Autorun components

There are four components to a home-made autorun:

  • The autorun.inf file
  • An autorun program (our batch file)
  • A file the program will open (the index.html file)
  • An icon for your CD when it appears in Windows Explorer (optional, and best left alone if you\'re a beginner as I won't be covering it here).

The batch file

A batch file is treated by Windows as a program, with the added advantage that it is simple to create. If you want to skip the file creation step, all these files are on the cover CD. As mentioned earlier, I'm assuming that you want to open a HTML file on the CD called index.html. Start Windows Notepad and type in the following, including the "@" symbols:

@echo Loading CD
@start index.html
@cls
@exit

Save the file as autorun.txt. Now change the TXT extension to BAT (i.e. autorun.bat) and confirm that you want to change the extension when asked by Windows. Its icon should now be a blue square with a little yellow cog in the middle. If you can't see the file extensions in Windows Explorer, you'll need to turn them on (from Windows Explorer choose Tools-Folder Options. Click the View tab and uncheck "Hide extensions for known file types".) The first line after @echo (there is a space after echo) will appear as a comment in the autorun launch window. This comment will be seen briefly by your end-users. This window will only appear for a second, so don't make it too wordy. If you wanted to say "The CD is loading now...", the first line will look like this:

@echo The CD is loading now...

The second line of the code is pointing to your index.html file. If you called it index.html, then it would read:

@start index.html

The final two lines (@cls @exit) clear the screen and close the launch window so the user now only sees the file you wanted to open.

The autorun.inf

The autorun.inf is responsible for telling Windows what program it should open. It must be called autorun.inf and nothing else. The file is created by writing two lines into a special text file. The best way to do this is to open Windows notepad, type in the code below and save the file as autorun.txt:

[autorun]
open= autorun.bat

Next, change the filename to autorun.inf and when Windows asks to confirm the extension change, click Yes. It should now have a little cog icon next to it.

The name of the file after "open=" must be the name of the program that will run when the CD is inserted. In this example, it's autorun.bat. If you called the file start.bat, then the line would be open= start.bat

Assembling the CD

You're now ready to create an autorun CD. In your CD burning program, copy the three files to the root directory of the CD. These are autorun.inf, autorun.bat and index.html. You can put any sort of files on the rest of the CD - they won't affect the autorun.

Here's what happens when the CD is inserted: autorun.inf tells Windows to run autorun.bat. This opens a small DOS shell window, which then opens index.html. If you want to see the system in action, download the zip file from the cover CD and unpack the contents.

Copy the three files (autorun.inf, autorun.bat and index.html) to the root directory of a test CD-R, burn the CD and give it a go. You should see a message saying "congratulations".

Fixing XP's autorun

Windows XP tries to be way too clever when it comes to autoruns and ends up being a great pest. Every time you insert a CD, XP takes a guess at the type of content on the CD and then launches a program or shows you a list of helpful and unhelpful options. Unfortunately this slows down the load times of a CD or DVD, plus it can be quite easy to accidentally click the wrong option or turn off the various autorun features altogether. To repair the autorun functions, Microsoft has a tool called the Autoplay Repair Wizard. It's buried deep on the Microsoft Web site, but shows up when you search for "Autoplay Repair Wizard".

Keep up with the latest tech news, reviews and previews by subscribing to the Good Gear Guide newsletter.

Scott Mendham

PC World

1 Comment

d'angle

1

Excellent article. That's exactly what I was looking for.

Comments are now closed.

Latest News Articles

Most Popular Articles

Follow Us

GGG Evaluation Team

Kathy Cassidy

STYLISTIC Q702

First impression on unpacking the Q702 test unit was the solid feel and clean, minimalist styling.

Anthony Grifoni

STYLISTIC Q572

For work use, Microsoft Word and Excel programs pre-installed on the device are adequate for preparing short documents.

Steph Mundell

LIFEBOOK UH574

The Fujitsu LifeBook UH574 allowed for great mobility without being obnoxiously heavy or clunky. Its twelve hours of battery life did not disappoint.

Andrew Mitsi

STYLISTIC Q702

The screen was particularly good. It is bright and visible from most angles, however heat is an issue, particularly around the Windows button on the front, and on the back where the battery housing is located.

Simon Harriott

STYLISTIC Q702

My first impression after unboxing the Q702 is that it is a nice looking unit. Styling is somewhat minimalist but very effective. The tablet part, once detached, has a nice weight, and no buttons or switches are located in awkward or intrusive positions.

Resources

Best Deals on GoodGearGuide

Latest Jobs

Don’t have an account? Sign up here

Don't have an account? Sign up now

Forgot password?