Join 132,654 Programmers for FREE! Get instant access to thousands of experts, tutorials, code snippets, and more! There are 1,145 people online right now. Registration is fast and FREE... Join Now!
I wish to have a USB thumb drive automatically launch an application when inserted into the port on Windows Vista and XP machines. No prompting the user for which application they want to run, no asking if they always want to perform this action, just an immediate launch of the application, specified by the autorun file located on the drive.
The problem:
XP and Vista do not support this functionality to my knowledge for what it considers removable media like a thumb drive...only for static media (CD/DVD) or non removable media (hard drives). A security setting is in place that overrides the autorun file on the drive, and uses the Windows AutoPlay functionality (this is a valid security procedure, just very inconvenient to me). the security feature can be overridden, but must be done on a machine by machine basis (I will not be able to do this is a mass production environment). As a result, the autorun file does not get a chance to do anything like I'd want it to (launch an app, run a bat file that launches an app, mount itself as a drive and run a bat file, etc...)
Potential solutions:
1. The most obvious solution (to me anyway) is to trick the OS into thinking the USB drive is a CD. to do so, the drive would need to be partitioned into a CDFS partition on which the autorun file and application can be placed, and potentially a data partition for other files. M question is this: What software can I use to create a CDFS partition on a thumbdrive (keeping in mind this would have to be done programatically at some point)? Does your average thumb drive support this type of partitioning. 2. Second most obvious solution (again to me only) would be to create the actual physical CD with all required functionality, rip an ISO of the CD, and then put that ISO on the drive in such a way that the drive is recognized as a CD. Does this sound feasible?
This problem manifests itself only on XP and Vista.
You can make a USB thumb drive act like a CD. I don't know the specific steps for it off hand, but I know the SanDisk Cruzer thumb drives do this. When a brand new one is connected to a PC, it will auto-mount as 2 drives. One is the thumb drive, the other is the CD image on the drive. It has been a while since I dealt with this because I used the software to remove the feature from my thumb drive, but I seem to recall it auto-running a program. I would suggest looking into this as a starting point.
Thank you...I actually did, and should have mentioned it. the Cruzer's were about the only drive i found that did this. since I'm looking at a mass production environment, the Cruzer's themselves may be cost prohibitive. i'm also looking to see what process they used to partition the drive. I've got a bad feeling it may be a combination of software/hardware.
I know this sounds crazy, but have you tried e-mailing SanDisk and asking how they did it? They might be willing to just tell you, or set you up with someone who knows.
Dang, noone mentioned my autorun tutorial, right here in the software development tutorials! Anyway, on my XP it seems to work autorun with a usb drive, and if it doesn't, you could try tricking your computer with subst, though that kinda puts the cart before the horse, since the batch file that subst es the flash drive to run autorun has to be run automatically, which requires autorun Screwy windows
By the way, this page has some good info on autorun and such, and might hold the answer, though of course, i'm too lazy to look : http://en.wikipedia.org/wiki/Autorun
So for either of the previous 2 posts, are you telling me that that you can stick a thumb drive into any xp or vista computer, and there will be an automatic launch of your app, with now Windows dialog box being launched? I've built several autorun files, and tried numerous machines - each time, a Windows dialog box is launched asking me what I wish to do with the content on the drive.
Not sure if I mentioned it, but I am aware that this security feature can be turned off by modifying the registry value - this is not an option that I will have, unfortunately.