School Assignment? Project Due Tomorrow? Chat LIVE With A Programming Expert!

Welcome to Dream.In.Code
Become an Expert!

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!




Autorun on a USB Drive - Windows

2 Pages V  1 2 >  

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: 13,284



Thanked: 149 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 offlineProfile 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: 1,040



Thanked: 4 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: 13,284



Thanked: 149 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 offlineProfile 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,648



Thanked: 58 times
Dream Kudos: 825
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 offlineProfile CardPM
+Quote Post

gabehabe

RE: Autorun On A USB Drive - Windows

19 Aug, 2008 - 10:18 AM
Post #5

Sexy DIC
Group Icon

Joined: 6 Feb, 2008
Posts: 8,864



Thanked: 177 times
Dream Kudos: 3275
Expert In: Lots of things.

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 offlineProfile CardPM
+Quote Post

polymath

RE: Autorun On A USB Drive - Windows

19 Aug, 2008 - 10:32 AM
Post #6

D.I.C Addict
Group Icon

Joined: 4 Apr, 2008
Posts: 650



Thanked: 21 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: 13,284



Thanked: 149 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 offlineProfile 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: 440



Thanked: 37 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: 13,284



Thanked: 149 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 offlineProfile 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: 13,284



Thanked: 149 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 offlineProfile CardPM
+Quote Post

polymath

RE: Autorun On A USB Drive - Windows

19 Aug, 2008 - 11:33 AM
Post #11

D.I.C Addict
Group Icon

Joined: 4 Apr, 2008
Posts: 650



Thanked: 21 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 ninja
Group Icon

Joined: 30 Dec, 2007
Posts: 2,144



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

RodgerB

RE: Autorun On A USB Drive - Windows

19 Aug, 2008 - 01:34 PM
Post #13

D.I.C Lover
Group Icon

Joined: 21 Sep, 2007
Posts: 2,238



Thanked: 33 times
Dream Kudos: 2200
Expert In: Dot Net Technologies

My Contributions
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 wonder what happens with Linux...
User is offlineProfile CardPM
+Quote Post

NickDMax

RE: Autorun On A USB Drive - Windows

19 Aug, 2008 - 02:36 PM
Post #14

Can grep dead trees!
Group Icon

Joined: 18 Feb, 2007
Posts: 5,267



Thanked: 293 times
Dream Kudos: 1175
Expert In: Java/C++

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

Amadeus

RE: Autorun On A USB Drive - Windows

19 Aug, 2008 - 04:24 PM
Post #15

g+ + -o drink whiskey.cpp
Group Icon

Joined: 12 Jul, 2002
Posts: 13,284



Thanked: 149 times
Dream Kudos: 25
My Contributions
QUOTE(polymath @ 19 Aug, 2008 - 03:33 PM) *

Another good reference for your idea: http://www.dailycupoftech.com/usb-drive-autoruninf-tweaking/

Contains all you should need.

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". smile.gif

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.

User is offlineProfile CardPM
+Quote Post

Tom9729

RE: Autorun On A USB Drive - Windows

19 Aug, 2008 - 04:30 PM
Post #16

Debian ninja
Group Icon

Joined: 30 Dec, 2007
Posts: 2,144



Thanked: 53 times
Dream Kudos: 425
My Contributions
QUOTE(Amadeus @ 19 Aug, 2008 - 08:24 PM) *

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.

Sorry, I didn't really read the other posts. blush.gif
User is offlineProfile CardPM
+Quote Post

NickDMax

RE: Autorun On A USB Drive - Windows

19 Aug, 2008 - 05:44 PM
Post #17

Can grep dead trees!
Group Icon

Joined: 18 Feb, 2007
Posts: 5,267



Thanked: 293 times
Dream Kudos: 1175
Expert In: Java/C++

My Contributions
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
User is offlineProfile CardPM
+Quote Post

Nova Dragoon

RE: Autorun On A USB Drive - Windows

19 Aug, 2008 - 06:41 PM
Post #18

The Innocent Shall Suffer, Big Time
Group Icon

Joined: 16 Aug, 2001
Posts: 6,169



Thanked: 29 times
Dream Kudos: 515
Expert In: Python, Linux

My Contributions
What if you made a CD iso of what you wanted, then used something like *nix's dd to dump that onto the block device.

Maybe it would take?
User is offlineProfile CardPM
+Quote Post

Amadeus

RE: Autorun On A USB Drive - Windows

19 Aug, 2008 - 08:21 PM
Post #19

g+ + -o drink whiskey.cpp
Group Icon

Joined: 12 Jul, 2002
Posts: 13,284



Thanked: 149 times
Dream Kudos: 25
My Contributions
You're a mind reader Nova...that's what I'm trying first thing in the morning! smile.gif
User is offlineProfile CardPM
+Quote Post

polymath

RE: Autorun On A USB Drive - Windows

20 Aug, 2008 - 07:31 AM
Post #20

D.I.C Addict
Group Icon

Joined: 4 Apr, 2008
Posts: 650



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

2 Pages V  1 2 >
Fast ReplyReply to this topicStart new topic

Time is now: 11/21/09 01:40PM

Live Help!

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter Fan Us On Facebook

Tutorials

Programming

Web Development

Reference Sheets

Code Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month