Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'd like to run a given Perl script whenever I connect my camera to my PC, so that this script will download all the photos on it. But as the drive letter for the camera may change depending on what's already connected, I need to pass this drive letter as an argument to the script.

Is this possible?

share|improve this question
up vote 1 down vote accepted

As I wrote in your other question for this problem also USBDLM could be the solution. E.g. it could start your photo sync tool on connect or any script you like.

You can use the %DriveLetter% variable to be passed to your script. Here is an example configuration section:

open=your_script.bat %DriveLetter%

See the documentation for details (the included Windows documentation is much more readable).

share|improve this answer
But can it start the script and give it the path to the inserted drive as parameter? – Xavier Nodet Jul 31 '09 at 13:23
See my edited answer. – desolat Jul 31 '09 at 14:26

You could:

  1. Assign a different drive letter, then it will stay the same. This can be done in devmgmt.msc

  2. Instead of a drive letter, assign a filesystem path (like in Linux).

    For example, "C:\Users\Xavier\Desktop\USB key\" instead of "E:\". Again, devmgmt.msc

  3. Run mountvol, copy the \\?\Volume{blah-blah} path, replace the ? with a period . and use that path instead.

    For example, \\?\Volume{e095d6a2-a763-11dd-afc0-806d6172696f}\boot.ini in my computer is the same as C:\boot.ini. (Not sure if this remains static all the time - but it worked for me so far.)

share|improve this answer
The '\\?\Volume{blah-blah}' is a nice trick I did not know... But is it possible to have Windows give it to a script when the drive is inserted? – Xavier Nodet Jul 31 '09 at 13:27
I doubt it's possible to automatically run a script at all. – grawity Jul 31 '09 at 13:52

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .