Join 307,119 Programmers for FREE! Get instant access to thousands of experts, tutorials, code snippets, and more! There are 1,968 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.
I always thought the Cruzer's initialization (or POST) with the little menu was a part of the actual driver. My friend has one, and in the middle of it's initialization, it would remove the drive from the system (make that doo doo noise) and start it up again.
insert usb -> menu pops up -> usb miraculously disconnects for no good reason -> usb redetected -> menu goes away -> play warcraft.
I can't find a referance to support my claims, but I am about 98.9% sure this is a registry configuration issue.
I use autorun.inf files on all of my external drives (thumb or otherwise). This is how I give them their neat little icons that allow me to tell them apart.
you might try this:
Launch the group policy editor (gpedit.msc) and navigate to:
"Administrative Templates" > System > "Turn Off Autoplay" and select "disable"
It would indeed...if not for the fact that one of my stated requirements was to bypass the Windows dialog box. The method described uses the Windows AutoPlay functionality.
Thank you for your help - I should state that I am not new to autorun.inf files, but am specifically trying to skirt a Windows security measure.
QUOTE(NickDMax @ 19 Aug, 2008 - 06:36 PM)
I can't find a referance to support my claims, but I am about 98.9% sure this is a registry configuration issue.
I use autorun.inf files on all of my external drives (thumb or otherwise). This is how I give them their neat little icons that allow me to tell them apart.
you might try this:
Launch the group policy editor (gpedit.msc) and navigate to:
"Administrative Templates" > System > "Turn Off Autoplay" and select "disable"
not sure if that would have any affect...
You are correct - this would be a solution, but I'm afraid I won't have access to the end user machines to perform this action. The only contact I will have with them is through the thumb drive, and even if I could programatically change the registry configuration, that would have to be done via a program on the drive, which would trigger the windows dialog before the contained autorun.inf is executed.
It's an interesting problem.
QUOTE(RodgerB @ 19 Aug, 2008 - 05:34 PM)
I always thought the Cruzer's initialization (or POST) with the little menu was a part of the actual driver.
You are correct as well. the Cruzer employs a CDFS partition on the drive that auto launches it's software...but that partition is supported by Cruzer firmware. If I bought Cruzer drives, I could put my own auto launcher on that partition, but the fact that i may require thousands of these makes that solution cost prohibitive. I'd prefer to find a way to do this any USB drive of I can.
QUOTE(Tom9729 @ 19 Aug, 2008 - 04:16 PM)
I believe there's a mention of this on the Wikipedia page for "autoplay".
There is indeed...and reading that page informs one that disabling the autoplay dialog for windows vista and xp can be done on a machine by machine basis, which is not an option open to me...thus the desire to have the CDFS partition on the thumb drive.
There is indeed...and reading that page informs one that disabling the autoplay dialog for windows vista and xp can be done on a machine by machine basis, which is not an option open to me...thus the desire to have the CDFS partition on the thumb drive.
So... you disseminate a highly virulent virus that secretly enables autorun and then moves on. Since its operation is nearly benign it has a good chance of hitting a high percentage of your potential users.
Allow your virus to run for about 6 months and then release your product.
...just saying... its an option... (they probably would have done it in the 80's)
its unethical... but an option.... if you don't mind white collar prison...
This post has been edited by NickDMax: 19 Aug, 2008 - 05:46 PM
You can use AutoPlay to run a setup batch file (I know you can use some tricky batch programming to modify the registry), so the user would need to use AutoPlay once and then you would use standard autorun.inf, not sure if that would work for you.