Start Programs Automatically With USB Agent

Martin Brinkmann
Dec 11, 2009
Updated • Jan 1, 2017
Software, Windows software

USB Agent is a free portable program for Microsoft Windows devices to run automatic actions when USB devices are plugged in or removed.

It sometimes can be quite handy to start programs automatically when a USB storage device is connected to the computer system. This can be an USB flash drive or external hard drive for example.

Applications that come to mind are those that run automatic virus scans of the data on the drive, start True Crypt or another data encryption program if data on the USB storage device is encrypted, or programs to create automatic backups of the data stored on the device.

USB Agent

USB Agent is a portable software program that provides this functionality. It requires some manual preparation before it will execute the a program though, but this should not take longer than a few minutes most of the time.

The most important step in the process is the creation of a new file on the USB device that has to be named usbagent.inf. The following information need to be added to the file after its creation (with a text editor):


where start-app.exe and stop-app.exe need to be replaced with executable or batch files that the user wants to execute if the USB device is connected and disconnected. The executable and batch files can be stored on the USB device by using the format


where %basepath%\ is pointing to the root folder of the USB device.

USB Agent comes with an option to mount True Crypt containers that are stored on USB devices. This can be a handy option to automate the mounting of the encrypted container. The portable software is available at the developer's German website.

Other options that it makes available are to eject all on exit, show removal messages, or run applications on exit.

A link to Google Translate is listed at the top of the page to translate the page into a different language. The program itself is available in English and German and compatible with Windows 2000 and newer Microsoft operating system including Windows 7, 8 and 10, and Windows Server versions.

Closing Words

USB Agent is a useful program if you work regularly with USB devices and want certain actions to be executed whenever you connect on of these devices to a machine running Windows. The program has not been updated in a while, which you see most clearly in its support for TrueCrypt -- a program that is no longer maintained -- but it works just fine in newer versions of Windows.

While it is a bit of a hassle to configure the program, considering that you need to create the file manually on each USB device, it may help you save time and avoid forgetting certain processes that you want carried out whenever a USB device is connected to a computer.

software image
Author Rating
no rating based on 0 votes
Software Name
USB Agent
Operating System
Software Category
Landing Page

Tutorials & Tips

Previous Post: «
Next Post: «


  1. marc said on May 14, 2010 at 12:12 pm

    I downloaded this and am trying to get it to run a program when i insert the stick into my laptop, running 7. I cant work out the %basepath% syntax, can someone post an example of how it should be written to run example.exe in C:program files please?

  2. Cornflower said on December 18, 2009 at 4:47 pm

    I downloaded this the other day when they disabled autoruns at my office, and it works great as it runs known programs from known USBs.

    I have found two things that may result in a single suggestion:
    1. I have a Read-only stick that after logging onto its encryption opens the read-write portion. I cannot generate usbagent.inf on this stick.
    2. There is an insecurity in that someone can place a usbagent.inf file on the USB to run malware. The issue here is that the name of the file is constant.

    Suggestion (once I learn Germant o suggest it) that usbagent have an option to run usbagent.inf from the host computer, so that it can decide what file to call from the usb drive., anming it as one will.

  3. ilev said on December 11, 2009 at 8:37 pm

    Microsoft sees autoplay as a security risk and disabled the feature in Windows 7 as well as updated XP and Vista do disable it.

Leave a Reply

Check the box to consent to your data being stored in line with the guidelines set out in our privacy policy

We love comments and welcome thoughtful and civilized discussion. Rudeness and personal attacks will not be tolerated. Please stay on-topic.
Please note that your comment may not appear immediately after you post it.