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?


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).

| improve this answer | |

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.)

| 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. – user1686 Jul 31 '09 at 13:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.