Welcome to Dream.In.Code
Getting Help is Easy!

Join 136,792 Programmers for FREE! Get instant access to thousands of experts, tutorials, code snippets, and more! There are 2,324 people online right now. Registration is fast and FREE... Join Now!




Autorun on a USB Drive - Windows

3 Pages V  1 2 3 >  
Reply to this topicStart new topic

Autorun on a USB Drive - Windows, Can It Be done?

Amadeus
19 Aug, 2008 - 07:27 AM
Post #1

g++ -o drink whiskey.cpp
Group Icon

Joined: 12 Jul, 2002
Posts: 12,228



Thanked: 39 times
Dream Kudos: 25
My Contributions
The situation:

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.

I'm also open to any other potential solutions.
User is online!Profile CardPM
+Quote Post

Noldona
RE: Autorun On A USB Drive - Windows
19 Aug, 2008 - 08:19 AM
Post #2

Addicted to DIC
****

Joined: 2 Jul, 2002
Posts: 939



Thanked: 3 times
My Contributions
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.
User is offlineProfile CardPM
+Quote Post

Amadeus
RE: Autorun On A USB Drive - Windows
19 Aug, 2008 - 08:29 AM
Post #3

g++ -o drink whiskey.cpp
Group Icon

Joined: 12 Jul, 2002
Posts: 12,228



Thanked: 39 times
Dream Kudos: 25
My Contributions
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.

Thank you very much for your response.
User is online!Profile CardPM
+Quote Post

girasquid
RE: Autorun On A USB Drive - Windows
19 Aug, 2008 - 08:50 AM
Post #4

Barbarbar
Group Icon

Joined: 3 Oct, 2006
Posts: 1,267



Thanked: 14 times
Dream Kudos: 650
My Contributions
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.
User is online!Profile CardPM
+Quote Post

gabehabe
RE: Autorun On A USB Drive - Windows
19 Aug, 2008 - 10:18 AM
Post #5

Donkey DIC
Group Icon

Joined: 6 Feb, 2008
Posts: 5,548



Thanked: 98 times
Dream Kudos: 2650
Expert In: ruling the world.

My Contributions
I put an autorun on my pen drive before, and that did the trick.

I don't remember now, but I know it definitely worked~ I used it to launch PortableApps as soon as I plugged it in.

This tutorial has a great explanation on getting started with writing autorun.inf files.

If you want a menu, as with the "What do you want to do? Open folder, View pictures, etc..." you can customise that, too.

smile.gif

NOTE: That tutorial is for CD/DVD, but it works for pen drives too. happy.gif
User is online!Profile CardPM
+Quote Post

polymath
RE: Autorun On A USB Drive - Windows
19 Aug, 2008 - 10:32 AM
Post #6

D.I.C Regular
Group Icon

Joined: 4 Apr, 2008
Posts: 414



Thanked: 4 times
Dream Kudos: 500
My Contributions
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 smile.gif Screwy windows smile.gif

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 smile.gif : http://en.wikipedia.org/wiki/Autorun
User is offlineProfile CardPM
+Quote Post

Amadeus
RE: Autorun On A USB Drive - Windows
19 Aug, 2008 - 10:41 AM
Post #7

g++ -o drink whiskey.cpp
Group Icon

Joined: 12 Jul, 2002
Posts: 12,228



Thanked: 39 times
Dream Kudos: 25
My Contributions
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.
User is online!Profile CardPM
+Quote Post

mocker
RE: Autorun On A USB Drive - Windows
19 Aug, 2008 - 10:45 AM
Post #8

D.I.C Regular
Group Icon

Joined: 14 Oct, 2007
Posts: 258



Thanked: 15 times
Dream Kudos: 25
My Contributions
Autorun for USB requires SP2, so if you are testing it make sure your machine has that.

http://www.lazybit.com/index.php/2007/03/0..._autorun?blog=2
User is offlineProfile CardPM
+Quote Post

Amadeus
RE: Autorun On A USB Drive - Windows
19 Aug, 2008 - 10:51 AM
Post #9

g++ -o drink whiskey.cpp
Group Icon

Joined: 12 Jul, 2002
Posts: 12,228



Thanked: 39 times
Dream Kudos: 25
My Contributions
Yeah, that holds true for release 1 of SP2 of XP, but all XP versions, and I'm afraid not for Vista at all.
User is online!Profile CardPM
+Quote Post

Amadeus
RE: Autorun On A USB Drive - Windows
19 Aug, 2008 - 10:57 AM
Post #10

g++ -o drink whiskey.cpp
Group Icon

Joined: 12 Jul, 2002
Posts: 12,228



Thanked: 39 times
Dream Kudos: 25
My Contributions
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.
User is online!Profile CardPM
+Quote Post

polymath
RE: Autorun On A USB Drive - Windows
19 Aug, 2008 - 11:33 AM
Post #11

D.I.C Regular
Group Icon

Joined: 4 Apr, 2008
Posts: 414



Thanked: 4 times
Dream Kudos: 500
My Contributions
Another good reference for your idea: http://www.dailycupoftech.com/usb-drive-autoruninf-tweaking/

Contains all you should need.
User is offlineProfile CardPM
+Quote Post

Tom9729
RE: Autorun On A USB Drive - Windows
19 Aug, 2008 - 12:16 PM
Post #12

Debian guru
Group Icon

Joined: 30 Dec, 2007
Posts: 1,461



Thanked: 10 times
Dream Kudos: 325
My Contributions
I believe there's a mention of this on the Wikipedia page for "autoplay". smile.gif
User is online!Profile CardPM
+Quote Post

3 Pages V  1 2 3 >
Fast ReplyReply to this topicStart new topic
Time is now: 12/3/08 01:37PM

Live Help!

Tutorials

Programming

Web Development

Reference Sheets

Code Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month