Fog Creek Software
Discussion Board




AUTORUN woes on USB drive

I have a removable USB drive and every time I plug it in, Windows XP searches it and presents me with a list of options like "Open folder to view files" "Take no action" and others, depending on what it finds.  This is because there is no AUTORUN.INF in the root directory, and I understand this much.

Well, I want it to "Open folder to view files" automatically, but I can't figure out how to do this.  I've tried simply opening "EXPLORER.EXE" in sundry ways, but it doesn't open it in the same way as if I choose the "Open..." option from the dialog.  I can't really describe how it's different, but it is.  For example, I don't have to have to hard-code the drive letter in the AUTORUN.INF, and when it does open Explorer, it doesn't know about the volume label, etc.  It's different in that "this isn't right" sort of way.

I've tracked down the choices presented in the registry to the key:
HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\AutoplayHandlers\Handlers

I always want it to use the "MSOpenFolder" handler for this specific drive.  How or can I do this?  I assume there's a magic recipe for an AUTORUN.INF that will do this.

I've tried RUNDLL32'ing the "Action" key's value, but that doesn't work.  RUNDLL32 complains that -17154 isn't a valid entry point, etc.

It seems like this should be a simple thing to do...

Gabriel Krupa
Wednesday, March 10, 2004

Seems like the forum software/CSS/HTML/whatever has clipped the registry key.  It's:

HKLM\
  SOFTWARE\
  Microsoft\
  Windows\
  CurrentVersion\
  Explorer\
  AutoplayHandlers\
  Handlers

Gabriel Krupa
Wednesday, March 10, 2004

Is the fact that you're trying to do it all from AUTORUN.INF your problem? Why don't you just write a bit of code to do it, and have AUTORUN execute your program instead?

Brad Wilson (dotnetguy.techieswithcats.com)
Wednesday, March 10, 2004

EXPLORER.EXE has a number of commandline switches and options.  I suggestion you look into that; one of the switches might be what you are looking for.

Almost Anonymous
Wednesday, March 10, 2004

Your assumption that the handlers registry is somehow related to AUTORUN.INF is not quite right.  Windows XP does not rely solely on AUTORUN.INF to determine what to do with a disk.  It has the ability to try to determine what sort of media is on the disk, and take a registered action based on the type of media (ie, play a DVD in your dvd software).  All this happens without an AUTORUN.INF file.  I'm not sure if you can set it up to do something based on the drive alone, like you want.  Have you tried selecting the "Open" option and checking "always do this for this type of disk" or whatever the checkbox is?

MikeMcNertney
Wednesday, March 10, 2004

Calling explorer from AUTORUN seems to be "broken" in the way mentioned above always, no matter what/how I call it.

For example, if I open a new Explorer after the drive is attached, it usually doesn't even show up as a drive under "My Computer" (no, refreshing doesn't help--it just isn't there).  I can manually type in the drive letter and see it then, but now we're back to the volume label and hard coding letters issues.

I've had other problems with other media, which appear similar to the "brokenness" I'm describing--like a USB key drive that wouldn't let non-8.3 filenames be used except from the "special" Explorer started from the Autorun detect dialog.  I could see the files, but couldn't create a new file that violated the old 8.3 limit.

The magical, lovely, special Explorer I'm talking about had no such problem.  It was as if it was looking at a different device (maybe some special info is being passed to Explorer when started in the autorun special way).

If I closed the singular wonderous window of many splendors, I had to re-connect the damn device to create files with meaningful names.

If I knew more about the NT device namespace I'd try opening $Devices/Bus/USB/blah or whatever.  Maybe a different path to the device is what's different.

I assume there's some interface for telling SHELL32.DLL what to open and what its capabilities are when called via the autorun handler, else how would it know which device to view?

Gabriel Krupa
Wednesday, March 10, 2004

there's probably a setting for what you want to do, maybe in tweakui or annoyances.org

have you tried autorun.inf pointing to autorun.bat
autorun.bat has one line

start .

mb
Wednesday, March 10, 2004

or

explorer %~d0%~p0

mb
Wednesday, March 10, 2004

if all you want to do is stop XP from displaying that annoying dialog when you plug in USB drive then download XP TweakUi and in the autoplay options uncheck your usb drive letter

http://www.microsoft.com/WINDOWSXP/home/downloads/powertoys.asp

Code Monkey
Wednesday, March 10, 2004

Doesn't the dialogue also include a "Always perform the selected action" checkbox, so why don't you elect to open the folder and then check that?

John Topley (www.johntopley.com)
Thursday, March 11, 2004

Autorun.inf does not work for "removable media" like USB drives, only for CDs etc.  AutoPlay is used instead:
http://msdn.microsoft.com/msdnmag/issues/01/11/Autoplay/default.aspx

Skye Legon
Thursday, March 18, 2004

*  Recent Topics

*  Fog Creek Home