PARTNER

Minggu, 24 Januari 2010

Using AutoRun with a USB Flash Drive

The AutoRun technology in Windows is often used to start programs and open menu interfaces on a CD and DVD automatically. But it is possible to do the same with a USB flash drive / USB memory stick? Can the AutoRun technology be used with a USB flash drive?


USB flash drive / USB memory stick
A typical USB flash drive
Most of us have today a USB flash drive (sometimes also referred to as a USB memory stick) that we use when we want to store data temporary. They are small and lightweight and are very practical when you want to move files from one computer to another. Before we often burned the data to a CD or DVD, but using USB flash drives are faster and they are easier to handle and they can store more data. And they are so small that you very easy can store them in your pocket.

USB flash drives are often used when data is moved between home and office. They are also very often used when data is moved inside an office, for example when moving data to/from a computer that is not connected to a network. They are also practical if you want to start small special programs that don't need installation and is not normally located in a computer.

Nowadays some companies have also started to distribute software, documents, movies and music via USB flash drives. Because they are so fast an application that is placed in a USB drive are started immediately. And large documents are shown very quickly. But when placing programs, documents etc in a USB flash drive, the same problem that was common with CD and DVD also occurs here. How can the end-user quickly find the program or document he/she wants to open?

With CD's and DVD's the AutoRun technology in Windows was used to start a particular program or open a particular document automatically. But is this possible also with a USB flash drive?


Using AutoRun with USB flash drives

If you place an Autorun.inf file in the root folder of a CD or DVD and the Autorun.inf file contains an OPEN command pointing to a program file (e.g. OPEN=MYAPP.EXE), the program is launched automatically when you insert the CD/DVD in a drive. But if you place the same Autorun.inf file and program file in a USB flash drive and plug the drive to a USB port in a computer, the program is very likely not started automatically. Instead is a Windows menu shown, that contains a list of actions (commands) you can do on the USB drive.


The AutoPlay dialog box in Windows

The dialog box that is shown when you insert a USB memory stick in a computer is called the AutoPlay dialog box. This dialog box is also shown when you insert a CD/DVD with no Autorun.inf file in a computers disc drive.

With a CD and DVD this dialog box can be suppressed if an Autorun.inf is placed on the disc. Unfortunately this is not possible, by default, with a USB flash drive. It is possible to change the behaviour of the drive by changing settings in Windows, and there exists also programs that can do this automatically, but most users don't have AutoRun turned on for USB flash drives. You can never expect that a random chosen user has this option turned on.

Well, this was the bad news. So where are the good news? Are there any? Yes, we have some good news. One good news is that there is a new command that can be used in the Autorun.inf file that almost give the USB flash drive AutoRun capability. The name of the command is ACTION and this command can display a user-defined text row in the AutoPlay dialog box. A text row that is connected to the OPEN command in the Autorun.inf file. This text row is always shown as the first item in the action list and it is also selected by default. So the user only needs to press Enter or OK to launch the program that is specified by the OPEN command.


In Windows Vista it is easy to make a USB flash drive 100% autostarting - if the user wants

There are more good news to tell. In Windows Vista it is quite easy for the Vista user to make a USB flash drive completely autostarting. In Windows XP it can be quite complicated to do this job without a special program, so most user will probably never try this, but with Windows Vista this can be done within seconds by using the AutoPlay dialog box itself. In the bottom of the AutoPlay dialog box there is a link with the text "Set AutoPlay defaults in Control Panel" and by clicking there the user can change the behaviour of the drive - he/she can for example make the drive completely autostarting.

It is hard to speculate how many users that actually will change the default settings, but if users feel that they want to have USB flash drives autostarting, they can do it very easy in Windows Vista.


How to use the ACTION command in an Autorun.inf file

It is very simple to use the ACTION command in an Autorun.inf file. Below we show an example of how this command can be used:

[AutoRun]
OPEN=MYAPP.EXE

ICON=MYAPP.EXE
ACTION=Start my application


In this example the ACTION command will place the text "Start my application" in the AutoPlay dialog box in Windows. The item with this text is placed as the first item and it is also selected by default. Next to the text, the icon specified by the ICON command is shown. And when the user chooses the selected item, the program file specified by the OPEN command is launched.


How to give the USB flash drive a label / title

We can improve this further. We can give the USB flash drive it's own label. This label text is also used as a dialog box title in the AutoPlay dialog box. To specify this text, a command with the name LABEL can be used in the Autorun.inf file. Below we show an example of how to use this command:

[AutoRun]
OPEN=MYAPP.EXE

ICON=MYAPP.EXE
ACTION=Start my application
LABEL=My Drive


In this example the USB flash drive has been given the label "My Drive". This label is displayed before the drive letter in Windows Explorer and as a dialog box title in the AutoPlay dialog box. Below we show how the AutoPlay dialog box will look like in Windows XP when using the Autorun.inf file above:

AutoPlay dialog box in Windows XP

More information about the LABEL command and other commands mentioned in this article can be read on this Microsoft page: Autorun.inf Entries. A short commands reference is also available on this page on our site: Autorun.inf - Commands.


USB flash drive with a menu interface

It seems that is possible to give a USB flash drive / USB memory stick a behaviour that is very similar to autostarting CD's and DVD's. The only difference is that the user must press Enter or OK before the program is launched or the document shown, but after doing that things works in the same way. And in Windows Vista we can sometimes be so lucky that the flash drive is 100% autostarting. This is interesting because this means that we can have a particular program started in the USB flash drive when it is plugged in the USB port.

Example of an AutoRun menu interfaceOne very interesting use is to have a menu interface shown automatically when the USB flash drive is plugged in the USB port, in the same way that a menu is shown when a commercial CD or DVD is inserted into the disc drive. This seems to be possible. If, for example, the menu program has the filename "MYMENU.EXE", an Autorun.inf file with the contents below can be created and placed in the root folder of the USB flash drive to handle an automated opening of the menu:

[AutoRun]
OPEN=MYMENU.EXE

ICON=MYMENU.EXE
ACTION=Show Menu
LABEL=My Menu



Software that can create an (autorun) menu interface to a USB flash drive

Although it is not complicated a create an Autorun.inf file, it is more time consuming to create a menu interface. There exists lot of products on the market that can create menu interfaces and some of them can also automatically create the necessary Autorun.inf file that is needed to create an autostarting USB flash drive. At our company we have a product named SamLogic CD-Menu Creator, that can be used to design and build autorun menu interfaces. If the menu will be used on a USB flash drive, CD-Menu Creator will create the necessary Autorun.inf file automatically.


Source : http://www.samlogic.net/articles/autorun-usb-flash-drive.htm
Share:

0 komentar:

Posting Komentar

Blog Archive

Blogger templates