Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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

2 Answers 2

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:

[OnArrival1]
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

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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