Results 1 to 3 of 3
  1. #1
    Join Date
    Dec 2004
    Location
    Madison, WI
    Posts
    3,926

    Unanswered: Auto-Run a program on a USB thumb key

    Is there any samples of a way to auto-run a program on a USB thumb key when that USB thumb key is connected?
    Expert Database Programming
    MSAccess since 1.0, SQL Server since 6.5, Visual Basic (5.0, 6.0)

  2. #2
    Join Date
    Dec 2004
    Location
    Madison, WI
    Posts
    3,926
    OK, I found a neat way to automatically run a usb thumb key program when the usb thumb key is connected (it's very simple utilizing the autorun.inf). Now I just need some code to run the "safely remove the usb key" icon.
    Expert Database Programming
    MSAccess since 1.0, SQL Server since 6.5, Visual Basic (5.0, 6.0)

  3. #3
    Join Date
    Dec 2004
    Location
    Madison, WI
    Posts
    3,926
    If anyone is interested here's some info to autorun a program when a USB thumb key is connected (Works for XP SP2 - not sure about other Windows versions.)

    Create a file called autorun.inf in notepad on the usb key (root directory).

    Here's some sample code for the autorun.inf file.

    [autorun]
    open=SampleGeocodingExtract.exe 'what your executable/bat is to run on the USB thumb key
    ACTION = Whatever Action I want it to show 'i.e. UPDATE GEOCODING FILES (CLICK HERE)
    icon=EARTH1.ICO 'icon you want displayed
    label=UPDATE GEOCODING FILES (CLICK HERE) 'Label I want displayed

    I was sceptical if it would work but it works pretty good. You still get a popup when the USB thumb key is connected but the program you want to run is the first/top item to select.

    Also, I downloaded QuickUnplug which has a command-line prompt to disconnect the USB thumb drive (to use in a vb script) but you need to install the program. I'm still looking for some vb/vb script code to automatically disconnect the USB thumb key without having to install 3rd party software.
    Last edited by pkstormy; 05-21-07 at 19:00.
    Expert Database Programming
    MSAccess since 1.0, SQL Server since 6.5, Visual Basic (5.0, 6.0)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •