USB Virus Scan is a nice little command line utility that performs predefined operations if a usb drive is connected to your computer. It is able to distinguish between various drives which means that you can add custom operations for the drives that you own and a general option for drives that are not recognized. The tool uses the volume serial number of the drives to identify them and perform the operation.
I can use the tool to start true crypt automatically when I insert my hard drive that has been encrypted by it, could start iTunes when I add my iPod and start a background virus scan if I, or someone else, connects a usb drive that is not known. Please note that the user who is adding the usb device has full control over the system which means that he could abort everything that you autostart. (like a virus scan)
The tool uses the following syntax which has to be added to a .bat file which has to be autostarted with windows.
USBVirusScan cmd /k %d:
A real example would look like the following. Say you do want to start the file antivirus.exe on drive c:\ whenever a usb device is connected. You would create a new bat file which is basically a text file with the .bat extension. Create the file test.bat in the same folder that usb virus scan resides. Add the following line to it.
USBVirusScan “c:\antivirus.exe” %d:
It is possible to add additional parameters. -c hides the command window, -i hides the tray icon, -e disables the exit menu.
I was not able to figure out how to create autostart entries that would use the volume name or volume serial number so I asked Didier the author of the software directly. The following paragraph is his answer to the question, thanks for being so quick to answer it Didier.
On my laptop, I have this entry in the Startup menu: “D:\Program Files\USBVirusScan\USBVirusScan.exe” wscript “D:\Program Files\USBVirusScan\tasks.vbs” %d %s ‘%v’ tasks.vbs will start TrueCrypt when I insert a USB-key with serial number “318606D2″ to automatically mount the TrueCrypt volume on the USB-key. If it’s my MP3 player that is inserted (volume name PackardBell), 2xEplorer is launched. And in any other case, a virusscan is executed. tasks.vbs:
dim WshShell
Set WshShell = WScript.CreateObject(”WScript.Shell”)
‘wscript.echo Wscript.Arguments.Item(2)
if Wscript.Arguments.Item(1) = “318606D2″ then WshShell.run “”"D:\Program Files\TrueCrypt\TrueCrypt.exe”" /v ” & Wscript.Arguments.Item(0) & “:\d1.tc /lz /q”, 1, true
elseif Wscript.Arguments.Item(2) = “‘PackardBell’” then
WshShell.run “”"D:\Program Files\2xExplorer\2xExplorer.exe”" D:\MyDirsD\Temp\PodcastQueue ” & Wscript.Arguments.Item(0) & “:\”, 1,
true
else
WshShell.run “”"D:\Program Files\Network Associates\VirusScan\csscan.exe”" /target ” & Wscript.Arguments.Item(0) & “: /secure /quiet /log “”D:\Program Files\USBVirusScan\log.txt”"”, 1, true
end if
You would have to edit the path and serial volume number to make the script usable but I think it demonstrates the usage nicely.
Related posts:
Scan downloads automatically with FirefoxCreate a secure USB Data Safe
True Crypt 4.2 released
Check which usb devices have been connected to your computer
Computer Virus Protection Quttera
Virus Total Uploader
Disk Encryption Software TrueCrypt 6.3 Released
Disable Automatic Virus Scanning in Firefox 3
3 Responses to “Autostart programs when a usb drive is connected”
Trackbacks/Pingbacks
-
[...] Autostart programs when a usb drive is connected [...]


Man I don’t know who you are, but you are one of my favourtite blogs. i visit you every day. Keep it up!
thank you
http://niquel757.blogspot.com
You mentioned that this program listens to windows events. Can you tell me which events in particular? Or direct me to some resource that introduces me to windows events. They look useful, but the names are not exactly friendly to new faces