« Free keylogger protection?How to get over the 4GB limit on FAT32 »

Autorun tool for removable USB flash drives

Autorun tool for removable USB flash drives

If you have a USB flash drive, then it is very likely that at some point in time you were interested in adding an autorun option, so that a program would start whenever the flash drive is plugged in. After several experiments, you probably concluded that it's not going to work, especially if you've read Microsoft's FAQ for driver developers.

The interesting fact is that somehow I actually managed to make it work. I haven't yet determined the key-factor which decides whether USB autorun will work or not, but the good old autorun.inf in the root directory approach still works. Apparently, USB autorun is allowed in XP SP2 (so SP2 is the key-factor), but I am not sure about that one yet.

So how does it work?
- create a blank autorun.inf in the root directory of the thumbdrive
- edit it with a text editor, the contents should be:


[autorun]
OPEN=PD\PrvDisk.exe /minimize /path:image.dpd /symbol:Z /RD
ICON=RunMe.exe
ACTION=Mount Private Disk

Notes:

  • ICON is an optional parameter, and it can be removed
  • OPEN should not be tied to any paths, use relative paths if you want to make sure that USB autorun will work correctly on computers that have a different number of drives and drive letters
  • ACTION can be customized, you can use any text

What is RunMe.exe you ask? In this case it is the EXE file the icon of which is used to represent the thumbdrive in the list of drives in My Computers. You can use an .ICO file for such purposes too.

However, RunMe.exe has another (more important) role. If autorun is disabled on a specific computer, you will not see the autorun menu when the thumbdrive is plugged in, hence the application will not start automatically. In that case you will be forced to explore the drive and run the program manually. But what if you need to launch the program with specific command line parameters? Open a console window and type the parameters there? Or use a .BAT script to do the same task?

The problem with BAT files is that you'll see a DOS window once the target application was launched, this window will have to be closed manually - and that takes time, and will soon become a very annoying procedure. RunMe solves this task by processing the autorun.inf file and running the program indicated in the OPEN section, along with its command line parameters [if any]. This will spare you from the tedious task of closing a console window (inexperienced users might not do that, being afraid of the consequences of an action they don't understand).

If autorun.inf is missing, or it contains invalid parameters (for instance - the path is invalid), the program will silently quit, without throwing any obscure error messages which can scare the hell out of newbies.
Follow this link to download RunMe USB autorun.

Tags: tips, usb, windows

29 comments

Comment from: Gary Smith [Visitor] Email · http://www.memory-x.com
Very interesting Alex.
Just what I was looking for.
I am looking forward to trying it on an application I am developing.

Gary
2007-03-10 @ 23:09
Comment from: Gary Smith [Visitor] Email · http://www.memory-x.com
Hi Alex,

I placed the Runme.exe and autorun.inf files on my Thumb drive.

I did get the "Removable Disk (E:)" window with the Runme Icon, which was exciting!

But when I clicked on "Mount Private Disk", It gave an error message:

E:\ Access is Denied

OH WELL
2007-03-27 @ 13:32
Comment from: Alex [Member] · http://www.dekart.com/
Can you post the contents of your autorun.inf file here? Taking a look at the paths will give me an idea about what goes wrong.
2007-03-27 @ 14:26
Comment from: PEJOL [Visitor] Email
E:\ Access is Denied

Try to visit http://infoklik.blogspot.com

it works well for me.
2007-04-06 @ 04:06
Comment from: Sean [Visitor] Email
How can I create and use a custom icon instead of the default RunMe.exe icon (compass)?
2007-05-08 @ 14:13
Comment from: Rudy [Visitor] Email
Alex,

Will this feature work on Mac systems?

Are there any restrictions on using RunMe commercially integrated into some software I am developing to be sold.
2007-05-19 @ 17:44
Comment from: Alex [Member]
PEJOL, 'access denied' will not occur when you attempt to start a file from the root directory of the drive; it will show up if you attempt to launch a file located inside a directory, or on another partition.

Sean, the icon can be changed by editing
ICON=RunMe.exe
Instead of RunMe.exe write the name of your ICO file, or the EXE file the icon of which you intend to use. Note that the icon of RunMe.exe cannot be changed (unless you recompile the program if you have its source code)

Rudy, unfortunately I think it will not work, because Macs have a different type of executable files. Moreover, they probably have a different approach to autorun on removable drives. I am not familiar with this platform so I cannot provide constructive feedback.
2007-05-21 @ 03:25
Comment from: Lauren [Visitor] Email
Will this work in Windows Vista?
2007-05-22 @ 14:37
Comment from: Dataloss [Visitor] Email · http://dataloss.ath.cx
I'm looking for a piece of software that can actually open the application without going through the hassle of a menu. If you know of such a program, email me at pikachu6517855@gmail.com
2007-05-22 @ 16:15
Comment from: Aamir [Visitor] Email · http://www.nowebsite.com
Fantastic,

Exactly what i was looking for
Works fine

Thanks
2007-07-26 @ 13:27
Comment from: Wayne [Visitor]
This is GREAT! I've been able to get the action loaded into the pop up window on XP SP2 and get the icon showing up too. I notice now that the little check/tick box at the bottom of that window that says 'always perform this action' is gone. Is there a way to specify in the autorun file to always do it?
2007-09-12 @ 05:47
Comment from: abdo [Visitor] Email
This is not working. How can you get runme.exe to run. It is not clear. I have tried it but does not work.
Am I missing somthing.

Regards,

Abdo
2007-10-23 @ 02:47
Comment from: Alex [Member] · http://www.dekart.com/
Abdo, it means that autorun is disabled, and you'll have to enable it. Try this:

  • Start regedit,
  • go to HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Cdrom
  • Set 'AutoRun' to 1
  • restart the system
2007-10-25 @ 02:22
Comment from: Anke [Visitor] Email · http://www.blackbit.net
There is a small utility that will enable the usb stick to autorun WITHOUT having to go through the menu. It's called DeskMount, and you can find it here:
http://www.blackbit.net/node/8

I've been using this one for a year, and it works great! It also works on Vista and XP SP1 by the way...
2007-10-31 @ 13:21
Comment from: Alex [Member] · http://www.dekart.com/
Looks like it can do the trick, but the problem with this tool is that it has to be installed on the computer. The probability that it is installed on another computer you intend to connect your USB disk to is extremely small.
2007-11-01 @ 02:33
Comment from: Avram [Visitor] · http://www.avramovic.info
This works fine, but M$ should enable ordinary autorun for USB drives by default
2007-11-22 @ 09:37
Comment from: Peter [Visitor] Email
I'm trying my best, but nothing happens after I plug USB stick...

Here is my autorun.inf:
[autorun]
OPEN=starttc.exe /minimize
ICON=RunMe.exe
ACTION=Start TC

It is expected to run starttc,exe

I monitored system, but RunMe.exe was not touched at all...

2007-11-25 @ 14:39
Comment from: amigo [Visitor] Email · http://onemilliontemplates.com
Nice article.Thanks, all problems are solved
2007-12-04 @ 20:24
Comment from: Alexander [Visitor]
Peter, Runme.exe is not supposed to be touched, according to your config.

It seems that autorun is disabled on your system, so you need to enable it, to do that, see the message from Alex, 2007-10-25 @ 02:22


The role of RunMe.exe is to do the job of the autorun.inf file if autorun is disabled - if that's so, simply click RunMe.exe and it will perform all the actions specified in the autorun.inf (this is the best you can do).
2007-12-05 @ 03:03
Comment from: Rae [Visitor]
What? How does this work? I'm an admin asst. with no tech experience and I think I get some of it but, its not working. I'm trying to run a pdf file and all of the literature I've found so far says anything you use has to end in .exe or .ico...I'm so confused! Can you offer help?
2008-02-27 @ 19:43
Comment from: Alex [Member] · http://www.dekart.com/
Rae, you'll have to take care of several things. First of all, you can't be certain that there is a PDF reader on the target system, therefore you'll need to place such a program on the USB disk as well. Try something like Sumatra PDF, as far as I know, it requires no installation and can be ran directly from a removable disk.

Second, see if the PDF reader supports command line parameters, and how they work.

In the end you'll have something like:


[autorun]
OPEN=PDFReader.exe MyDocument.pdf
ICON=RunMe.exe
ACTION=View the PDF


2008-02-27 @ 20:40
Comment from: Lewis Carey [Visitor]
I was unable to get this to work but have since discovered an alternate solution.
I downloaded mypendrive http://www.download.com/MyPendrive/3000-2094_4-10589782.html?tag=lst-3
and combined this with an autorun exe program at http://www.teapot.orcon.net.nz/autorun/autorunmaker.html
These combined allowed me to autorun a powerpoint from a flash drive...at last!
2008-03-06 @ 12:50
Comment from: Adrian Langlouis [Visitor] Email
It works, however, I have the same problem as indicated further up: I cannot select the "always do the selected action" flag in the popup..
2008-04-08 @ 19:07
Hi Alex,

I placed the Runme.exe and autorun.inf files on my Thumb drive.

I did get the "Removable Disk (E:)" window with the Runme Icon, which was exciting!

But when I clicked on "Mount Private Disk", It gave an error message:

E:\ Access is Denied

This is the autorun file I used:

[autorun]
OPEN=PD\PrvDisk.exe /minimize /path:image.dpd /symbol:Z /RD
ICON=index.htm
ACTION=Mount Private Disk
2008-05-20 @ 19:13
Comment from: Alex [Member] · http://www.dekart.com/
The program is caused by the fact that Windows does not allow files from sub-directories to be started if certain security settings are enabled.

In this case you will have to start RunMe manually, and it will take the parameters from autorun.inf and launch the specified program for you.

An alternative is to place the EXE you want to run in the root directory.
2008-05-26 @ 11:57
Comment from: Venturer [Visitor]
The program RunMe.exe has a bug.
If no command line parameters are specified it quits without and error message and without running the target program. I had to specify a dummy argument.

I need autorun for the icon, not commands.
2008-07-31 @ 17:44
Comment from: Alex Railean [Visitor] · http://www.dekart.com/
Hmm, that should not be the case; all errors will indeed be silently ignored, but if you give it a EXE name it will run it even if there are no other arguments.

Have you tried it with another EXE?
Can you tell me what's written in your autorun file? I could simulate the issue here and see what is happening.
2008-08-01 @ 11:36
Comment from: George Barrowcliff [Visitor] Email · http://www.barrowcliff.com
I have a flash drive that mounts as a 100 mb cd and a 900 mb removable drive.
The cd partition has an autorun and an executable. When the drive is plugged in, the autorun runs the executable.
Since the os treats the cd as read only files they cannot be deleted and I have been unable to delete the cd partition from the flash drive.
Every time this drive is plugged in, I get a full screen flash file of Minnie mouse throwing hearts around the screen. My coworkers love it.

How can I remove the cd partition from the drive?

Autorun.inf says
[autorun]
open=MINNIE.exe
and the executable is Minnie.exe of course.

Thanks,
2008-08-04 @ 01:59
Comment from: Alex Railean [Visitor] · http://www.dekart.com/
George, I'm afraid I don't have good news for you. I've seen such disks; this behaviour is hardcoded into them.

Maybe you can disable autorun and solve the problem 'the hard way'?
2008-08-04 @ 09:38

Leave a comment


Your email address will not be revealed on this site.

Your URL will be displayed.
(Line breaks become <br />)
(Name, email & website)
(Allow users to contact you through a message form (your email will not be revealed.)