Enabling autorun for a USB flash drive.
I'm a big fan of USB flash drives.. I first heard about the U3 flash drives some time ago, seems like it was pre-baby so at least last fall. I liked the idea of being able to sync desktop settings to my usb drive and have them applied when I plug into another system. I'm considering picking up one of the U3 compatible drives, but in the meantime I thought I'd see if I could come up with a poor mans solution.
The heart of the U3 niftyness is the autostarting. You plug in the USB drive, programs launch, settings are changed, all without you doing anything. Autorun has been around for years, since Windows 95 at least. To make your CD automatically start an application when you insert it, you create a file called autorun.inf and place it in the root of the CD rom. Say you want a file called foo.exe to autorun, your autorun.inf file would look like this.
-
[autorun]
-
open=foo.exe
-
icon=foo.exe
But with XP came something called Autoplay. Autoplay scans the media and pops up it's little nag window asking you what you want to do with your new found media. Without hacking the registry, you can't change this behavior. Some newer USB drives support autorun insertion. Out of the 5 drives I have, none of them supported it. All of them caused XP to display the Autoplay dialog. BUT you can add your own action to the Autoplay dialog box.
-
[autorun]
-
action= Run Foo
-
icon=foo.exe
-
open=foo.exe
Which then displays in the Autoplay dialog box.

For my main 512MB flash drive, I use the Pstart menu. This is a lightweight freeware menu program. It stays resident in your tray and allows you access to the menu by either right-clicking on it or opening up the full interface.
So with one click after inserting my flash drive, I have this nice menu to launch my portable applications from.

I'll investigate some of the syncing and automatic workspace configuration options in a later post. Right now I'm looking at Migo. None of the applications on my flash drive cost me a dime. Portableapps.com has a great listing of some of the more popular portible applications, as well as a couple of portable applications suites you can download and put on your flash drive.

May 1st, 2006 - 21:00
Cool! That’s some useful information you’re dropping. I just recently got a 1GB Cruzer Micro for my birthday. It’s really small and cool, but I don’t know what to do with it yet.
I work from home, so I don’t end up needing it on other computers often. I’ve got a great hammer here looking for some nails. Got any suggestions?
May 2nd, 2006 - 13:31
I’ve got a couple that I just use for source code when I travel. Makes it easy to pass around code at meetings. I’ll also export contacts, notes, documents, etc… when I go to a client site or some kind of meeting. Although I usually use my Palm Pilot for that.
Maybe you should get a few more and set them up in a striped RAID array?
June 2nd, 2006 - 19:09
Hi there,
Please can u tell me where you got that skin for Pstart – I love it!!
Thanks very much
June 3rd, 2006 - 05:59
Alex,
That’s actually a custom style for Windows XP using a hacked dll. You can get some isntructions on installing the hack and using a custom style over at Phils blog.
http://www.haacked.com/archive/2006/02/23/HowIPimpedMyDesktop.aspx
June 4th, 2006 - 06:13
Hey! Thanks for the reply Scott. Gonna check out the link now…
June 4th, 2006 - 06:55
Hi Scott, it’s me again! I’ve downloaded the patched Uxtheme and I was just wondering if you know the name of this visual style? Thanks again!
June 13th, 2006 - 08:22
Alex,
I’m not sure. That theme appears to have left my system? I’m pretty sure I got it at deviantart.com.
September 5th, 2006 - 09:29
That’s some cool info, but are you 100% sure that you can’t run an autorun.inf off a USB drive? I’ve heard there’s a windows component that returns a value of DRIVE_FIXED that prevents windows from searching for a autorun file. Is there a way to change the return value of the function with just the USB drive( no previous PC modifications required)?
September 8th, 2006 - 18:21
I’m never 100% sure, but I believe the way the U3 USB devices get around this is by reporting themselves as a CD Device, in which case AutoPlay is ignored and the autorun.inf is executed.
There are is a registry key that allows you to define handlers for specific USB devices ( they allow you to specify the USB device ID), but that requires at least enough security to edit the registry.
I couldn’t find anything on changing the return drive type fof the USB drive without changing the registry. I found this site that explains the drive type enums and how they relate to the autorun functionality a little better than I did though.
http://www.ashzfall.com/products/autorun/autorunfloppy.html
October 15th, 2006 - 17:42
Great stuff! You solved the exact problem I was trying to solve — how to launch the portable apps (TB, FF, etc.) from a thumbdrive.
Sadly, it doesn’t work for me though. When I try to launch my app from the autoplay menu I get an “access is denied, E:\” error. Since it’s parsing the autorun.inf and displaying the action, icon and label correctly I can’t fathom what it’s complaining about. Any ideas?
[autorun]
action=Start ThunderbirdPortable
icon=\ThunderbirdPortable\ThunderbirdPortable.exe
open=\ThunderbirdPortable\ThunderbirdPortable.exe
label=Portable Internet
October 18th, 2006 - 20:07
I’m not sure, I’ve never gotten that error when using autorun.inf. Some simple things to check.
1) Is the write-protect tab set on the USB drive?
2) If you don’t control the machine, does the admin have access to USB devices turned off?
3) Are any of the files that thunderbird uses or writes to set to read-only?
November 1st, 2006 - 11:09
how can i autorun a batch file without the dialog box of windows. simple insert and autorun and thats it ?? any one knows how this can be done? i have the inf file the batch but i wan the computer to automaticaly run the batch without prompting the user to open files cancel or run , just running the batch file thanks
January 21st, 2007 - 20:34
Bob,
You will find it should work if you write the file paths like so:
[autorun]
action=Start ThunderbirdPortable
icon=”ThunderbirdPortable\ThunderbirdPortable.exe”
open=”ThunderbirdPortable\ThunderbirdPortable.exe”
label=Portable Internet
I was having the same problem and this worked a treat.
November 18th, 2007 - 22:11
Hi Scott. I happened upon your post like a year after you’d made it! Hope I can still get a little help…
I got your suggestion to work just fine, but the autoplay pop-up only displays the very first program option (I placed multiple options following your “action” then “open” code lines but nothing displays past the first option).
Can you suggest anything more?
Thanks a lot! – Rene
December 12th, 2007 - 16:48
I have Windows Vista and Windows XP Machines.
I have tried several times.
Here is my Autorun INF file.
[autorun]
OPEN=Q:
ICON=\Icon\Flashdrive.ico
ACTION=USB Flashdrive
IT does not work.
I want to:
1. Display my drive icon in “my computer”. (Flashdrive.ico)
2 To have the drive open up. (displaying the flashdrive’s contents)
3. To open the Autoplay dialog box.
I am no programmer. Can anyone help me write this Autorun.inf file ?
mrgcav@gmail.com
December 12th, 2007 - 17:07
I was referring to a USB flashdrive in the previous post.
MRGCAV@Gmail.com