Endpoint

Projects and software by Matt Collinge @ www.mattcollinge.co.uk

USB Detect & Launch

with 18 comments

USB Detect & Launch allows you to automatically execute a script or application each time a USB storage device is plugged into your PC. Different scripts can be executed for different devices and it’s the volume label that determines what action to perform.

Some examples (dependent on the scripts you write) are:

  • Copy new podcasts to your MP3 player.. just like I describe here
  • Copy other media from specific folders onto your USB memory stick
  • Backup your USB memory stick automatically when it’s inserted
  • Backup files from your PC onto a portable hard drive (perhaps firing up a copy of Microsoft’s SyncToy or Robocopy)
  • Anything else you can think of that you can write in a script!

As I mentioned, the application does little more than detecting the USB device and launching a script determined by it’s volume label. The power comes from being able to write scripts to do whatever you like!

USB Detect and Launch

License

USB Detect and Launch is free for home use. Businesses must buy a license after an initial trial period of 10 days. The cost of a license is $40 per installation, payable via PayPal (which accepts Credit Cards).

Make payments with PayPal - it's fast, free and secure!

Downloads (for Windows 9x/200x/XP/Vista)

Download the Install Kit (212k)
Download the .zip (134k)
VB6 Runtimes for anyone who doesn’t already have them installed

Revision History

  • 29 Feb 2008 – Version 1.5 – Detects any devices that are inserted.. put ‘label:(any)‘ in your script. Note that this will also detect network drives & you really need to use the ignore setting to stop it detecting drives you don’t want the script to run for.
  • 13 Nov 2007 – Version 1.4 – Detects devices with no label.. put ‘label:(no label)‘ in your script
  • 4 Apr 2007 – Version 1.3 – Ability to launch additional scripts from the system tray menu
  • 25 Mar 2007 – Version 1.2 – Ignore certain drive letters (useful if performance is slow, or sleeping drives are spinning up)
  • 6 Feb 2007 – Version 1.1 – Minimise to system tray

Example Config

Here’s some example config you could use with the app:

label:BIGUN
exec:"c:\batch\batch-backup-bigun.cmd" %1 %2

label:(no label)
exec:"c:\batch\batch-backup-something.cmd" %1 %2

label:(any)
exec:"c:\batch\batch-backup-all.cmd" %1 %2

label:PENDRIVE
exec:"c:\batch\batch-insert-pendrive.cmd" %2
menurun:"c:\batch\batch-eject-pendrive.cmd" %2

ignore:d:\,e:\,g:\

Example Scripting

On my quest to automate my podcast downloads I have USB Detect & Launch running on my server & on my laptop where I watch most of the video-based podcasts.

When a new podcast is available, I’m notified by RSS and insert a 2Gb memory stick into my server. The script I use there is based on XCOPY and uses the /M parameter to copy all files with the archive attribute set, and reset that attribute once copied. Therefore the files only get copied once, but are still available on the server if I decide to watch them at home.

On my laptop I plug in the memory stick and another script that uses Robocopy will move all files from the podcast folder to an area on my laptop. Robocopy is used because XCOPY won’t actually move files from one folder to another.

The command line I’m giving Robocopy is:

robocopy “%1podcasts” “c:\podcasts” /MOV /V /NP /S

This traverses subdirectories, moves the files, yet preserves the folder structure. %1 is replaced by the drive that the USB memory stick appears on. Robocopy GUI is useful for building up the command line if you’re not sure of the parameters.

Legal

Disclaimer: A user of this software acknowledges that he or she is receiving this software on an “as is” basis and the user is not relying on the accuracy or functionality of the software for any purpose. The user further acknowledges that any use of this software will be at the user’s own risk and the copyright owner – Matt Collinge – accepts no responsibility whatsoever arising from the use or application of the software.

Written by Matt

January 25, 2007 at 1:52 pm

18 Responses

Subscribe to comments with RSS.

  1. Tried this out. Works OK!!
    I realize you just started but can you make it minimize to the ssytem tray on startup. Other than that it does just what i want.

    Thank you!!
    Paul

    paull

    February 4, 2007 at 9:23 pm

  2. Definitely; it’s next on my list. I’m intending to put exactly the same code into File Mover. Shouldn’t take long.. I just need to find a spare half hour to code it up :-)

    mattcollinge

    February 5, 2007 at 1:53 pm

  3. There you go.. Version 1.1 includes that feature. How’s that for service :-D

    mattcollinge

    February 6, 2007 at 5:36 pm

  4. Hi, great idea and program that looks like it does nearly exactly what I need need. One question though – is it possible for it to fire a script for any media inserted, irrelevant of the label on the card/usb stick. i.e. a “(any label)” equivalent of “(no label)”? I want to run a script irrelevant of what card is inserted with no prior knowledge of the card label.

    Thanks,
    Julian

    julianmclean

    February 11, 2008 at 12:06 pm

  5. I recently got hold of this program
    Excellent program
    I found a small issue
    The drive letter detection protocol is not the best so I am forced to add ignore option

    In ignore option you have to give all the existing drive letters i.e.: floppy drive(a:), HDD (c: and e:) CD drive (g:)

    Even after that it cannot handle a new drive letter which is greater than an existing removable drive letter i.e..

    If you have a USB drive with drive letter H existing and another flash disk is added and it is assigned a letter I the program will not launch the with I drive but with H drive. ie %1 is assigned H:

    But if it was visa versa i.e.. I drive was already present and H was added the program will launch with %1=H:
    I am sure it is a small bug which can be corrected.
    Maddy

    maddy2

    May 25, 2008 at 10:35 am

  6. Hi Matt,

    This is brilliant. Just what I was looking for. Works a treat on Win XP but how do I make it work on Vista? The task bar flickers but nothing happens.

    Has anyone made it work on Vista?

    Thanks, Chris

    cjakeman

    June 12, 2008 at 5:52 pm

  7. Oh really.. I’ve got it installed on my mother-in-law’s PC and it’s working fine under Vista. It fires up their backup software. I’ll have to take a look when I’m next over there & see whether they have any issues with the latest version.

    Matt Collinge

    June 19, 2008 at 8:04 pm

  8. Great app – when used with Robocopy it makes for a great backup stratagey. I would like the option though to backup ANY USB stick inserted into my computer and I suggest that a method be added that allows for this – ie, any stick gets the first script run against it (if there is one) and then the label gets checked and that script is run for subsequent USB drives.

    Can this be added?

    euginehax

    September 6, 2008 at 7:56 am

  9. Hey eninehax; try the ‘label:(any)’ option listed in the examples. Give me a shout if you have problems.

    Matt Collinge

    September 8, 2008 at 7:53 pm

  10. Hey there seems to be several bugs that are somewhat annoying

    A) You shouldn’t allow multiple instances of the application, it seems that the system really slows down when this happens.

    B) It seems (and maybe this is a limitation of how you are polling, only can detect that a change has occured, not necessarily what has changed), that you fire all events when any device is inserted. I think it should only fire an event for a given drive, when that drive is inserted.

    C) It seems that the execute command, i.e. Run Script on XXXXXXX, seems to take a VERY long time to run, i.e. a minute or two before it starts. Hitting the Start and Stop button, or inserting the drive cause the script to run right away.

    D) There was some sluggishness when using the validator with a large number of scripts.

    Suggestions:

    1) I think the BIG Start/Stop button looks bad.

    2) On Disconnect option – I realize that for a few reasons this is impossible, but it would be really cool if you could have a button that that lets you run a script, and when it finishes running, disconnects the drive (if possible). Obviously if you don’t disconnect the drive this way it won’t happen, but for what I’m using your application for it would be nicer.

    Otherwise Great App, Thanks.

    sjrx

    November 23, 2008 at 6:31 am

  11. Hi Sjrx; thanks for the comments;

    a) Guess that’s lazy coding on my part.. I just assume ppl won’t run it more than once.

    b) Yup; it only detects when a change happens.. it’s looking for new/changed system volume names & has no code in it to look at the USB devices directly.

    c) Execute script works fine on my systems.. for short scripts it completes almost instantly, whereas others (that do a whole bunch of processing) will take longer. Sounds like it’s a system issue at your end.

    d) Wow; how many scripts??

    1) Heh heh.. well I guess so, but on my systems it’s mimimised on start + automatically starts.. so I never really see it. It’s pretty much a run and forget about it app.

    2) Have you tried the ‘menurun’ option? That will give you a menu item which you can script per device, giving you exactly what you’ve asked for.

    Matt

    November 23, 2008 at 10:07 am

  12. Hey Matt,
    Just downloaded your program, yet I know nothing about coding. I just need a really simple script that runs Microsoft SyncToy as soon as the USB drive is plugged in. I am willing to PayPal you money if you could write me the script that would work.
    Thanks for your time,
    Stefan.

    stefanpa

    November 25, 2008 at 5:03 am

  13. Geez I am funny, you can email me at spazlack AT hotmail DOT COM
    Thanks !

    stefanpa

    November 25, 2008 at 5:06 am

  14. I realize this post is pretty old, but I figure it’s worth a shot. I downloaded your app (which works great, by the way), but wanted to check out the source code to see how this sort of thing is done. Is it available at all?

    eggplantburger

    November 9, 2009 at 7:58 pm

  15. [...] something like this? USB Detect & Launch You would have to email him and ask if a school counts as a business for his licence model. [...]

    USB backup woes

    May 19, 2010 at 12:05 pm

  16. People interested in this may also be interested in USBDLM.

    http://www.uwe-sieber.de/usbdlm_e.html

    Probably the best free USB management tool on the Planet.

    profquatermass

    October 25, 2010 at 8:14 am

  17. [...] Tools März 12, 2011 21:11 by Administrator http://mattcollinge.wordpress.com/software/usb-detect-and-launch/ [...]

    Blog J.Schweiss | Tools

    March 12, 2011 at 11:11 am

  18. I will be happy to donate if you can right a script for me. I want it to auto detect any usb inserted in to pc and auto download all content in the background with out the user knowing.

    vincentzul

    August 7, 2013 at 1:36 am


Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.

%d bloggers like this: