How To Auto-Launch Apps With A USB Stick [Windows]
Imagine having a USB stick with all of your favorite apps on it. Maybe a collection of PC troubleshooting utilities if you’re an IT tech, or maybe an assortment of spreadsheet and word processing tools if you’re an executive road warrior. Wouldn’t it be pretty sweet if you could just walk up to any computer, put your USB memory card into the USB port, and have your favorite portable apps automatically launch without any effort on your part?
Over the years, system administrators have come up with various tricks to accomplish this task. Tim wrote about a few useful ways that people use Windows Task Scheduler to launch various jobs, and Varun covered a series of useful USB apps that can come in handy. In this article, I’m going to cover a few USB auto-launch techniques that administrators have used. You might have been told that it’s impossible to auto-launch applications on your USB card on your Windows 7 computer. I’m here to show you that it is not true.
How You Used to Auto-Launch USB Apps
For years, at least since Windows 2000, but probably even earlier, system administrators have used the autorun.inf technique to autostart applications on a USB memory stick just like the autorun feature worked on computer CDs.
The autorun.inf file could be as complicated or as simple as you liked. The simplest form was as follows:
[autorun] icon=mypic.ico open=start-zim.bat action=Click “OK” to start your apps!
All you would need is the icon image and the batch job available, and the moment you inserted your USB stick into a computer running an OS like Windows XP, you would see the following options automatically pop up.
Just click OK and you’re good to go. You can launch a batch job that starts all of the apps that you want, and you essentially have a customized way to open up all of your apps in an automated way that saves a lot of time.
This was somewhat limiting, because you had that pop-up prompt. I’ve heard that there were ways to get around the pop-up that involved a little bit of tweaking/hacking, but in doing so you introduce the ability to hack any computer with some virus simply by inserting a USB stick. Microsoft caught on to this in Windows 7 and completely disabled the USB functionality of autorun.inf in that operating system. Future updates of Windows XP also disabled that feature. So what’s a system admin to do?
Launching Apps Automatically From Your USB Stick
Well, where there’s a will there’s a way. And yes, there is a way to launch a program just by inserting your USB stick into a Windows 7 PC.
The first thing you’re going to want to do is install AutoIT , which Guy covered a while back. AutoIT is a very cool scripting language that lets you compile those scripts into exec programs that you can distribute to any PC. The download includes an editor as well as the converter software.
The great thing about AutoIT scripts is that there are lots of brilliant people out there creating scripts for a long list of tasks. The following script is what you use to detect whether a USB stick has been inserted into a port.
$DBT_DEVICEARRIVAL = "0x00008000"
$WM_DEVICECHANGE = 0x0219
GUIRegisterMsg($WM_DEVICECHANGE , "MyFunc")
Func MyFunc($hWndGUI, $MsgID, $WParam, $LParam)
If $WParam == $DBT_DEVICEARRIVAL Then
MsgBox(4096, "Info", "My Drive has been Inserted, Backup My Files!")
$GuiMsg = GUIGetMsg()
That script will recognize a “device change”, and for a USB stick it will launch a message box, as shown here.
Now, think about that. If this script will recognize a USB stick in order to launch a message, then it can be slightly modified to launch a program instead. So, in order to do this, I took the script above and replaced the MsgBox command with the following line:
Run ("F:\System\Apps\ZimWiki\Zim Desktop Wiki\start-zim.cmd")
What this does is senses when I’ve plugged in my USB stick, and then automatically launches the Zim Wiki app I have on my USB stick that I use to organize and monitor my writing work.
Now we have a way to auto-launch a program just by inserting the USB stick. However, let’s take it a step further and launch a whole collection of apps by launching a batch job on your USB card called startapps.bat that launches all the programs you want for that particular stick.
START - F:\System\Apps\ZimWiki\Zim_Desktop_Wiki\start-zim.cmd
START - C:\Users\Owner\MUO_STORY_IDEAS\MUO_STORY_IDEAS.txt
START - FIREFOX.EXE //www.makeuseof.com/wp-admin
What’s the point of this? The point is that now you can have a unique “startapps.bat” script for various USB sticks. One might be for your school work, in which case you’d open your class webpage, a word processor and maybe a spreadsheet for the class. Another might be for your work as a help desk tech, where it would auto-launch PC support utilities and your favorite tech website (MUO of course).
The only catch is this – the EXE file you create with the AutoIT script has to be running on every PC that you want the auto-launch to occur on. This satisfies the Windows 7 security demands. Just open the AutoIT script above, and compile and build the script to create your EXE file. Put that EXE in the Startup folder of the computers you use most often.
If the script is running, you’ll see the following Icon in the task bar.
This setup is great because there’s no prompt at all – just insert your USB stick and all of your required apps will just launch automatically.
Give the script a try and see if you can get this setup working with your own USB stick. Do you like this approach? Any tips for how to improve it? Share your insight in the comments section below.
Affiliate Disclosure: By buying the products we recommend, you help keep the site alive. Read more.