How To Auto-Launch Apps With A USB Stick [Windows]

usbstick2   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.

yourapps1   How To Auto Launch Apps With A USB Stick [Windows]

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
 GUICreate("")
 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!")
 EndIf
 EndFunc
 While 1
 $GuiMsg = GUIGetMsg()
 WEnd

That script will recognize a “device change”, and for a USB stick it will launch a message box, as shown here.

autostart2   How To Auto Launch Apps With A USB Stick [Windows]

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.

autostart3   How To Auto Launch Apps With A USB Stick [Windows]

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 http://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.

autolaunch4   How To Auto Launch Apps With A USB Stick [Windows]

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.

ramasamy chidambaram

The comments were closed because the article is more than 180 days old.

If you have any questions related to what's mentioned in the article or need help with any computer issue, ask it on MakeUseOf Answers—We and our community will be more than happy to help.

7 Comments -

0 votes

TC4Drifter

What if autorun is disabled?

0 votes

DanieL

This doesn’t have to do anything with autorun, this is a program that detects when you plug your usb drive and launches a batch file that opens your applications.

0 votes

Ryan Dube

Daniel’s right – it’s an alternative method to using autorun, since autorun doesn’t work for USB on Windows 7.

0 votes

stuart

Hmm, nice idea. My Father-in-Law wants to make a USB key capable of launching a speech program (as he’s blind) on any computer that the key is plugged in to. That way, he can navigate and fix it, using a familiar voice rather than trying blindly to find the built-in Microsoft one. I had thought about UnetBootIn, but scripting may also be an idea. He was a dab hand at Visual Basic believe it or not!

0 votes

Ryan Dube

Visual basic will do it (I love VB). It may be possible to get such a concept working, but it would take more time and effort than I have available…the best I could manage is having a “watchdog” script running that watches for the insertion of a USB script. I’m not sure a USB-only solution is available anymore with the Windows security environment the way it is now.

0 votes

Kurt A Kruger

Ryan,
Your auto-start for USB sticks doesn’t work. When I plug it in to my computer at home it has a different device letter than at work or at my friends house.

0 votes

Ryan Dube

Hi Kurt – yes, that is right. You have to be sure to assign the USB with the drive letter you used when you set this up, otherwise you can’t use it on different computers. Each new computer you use it on needs to have the USB stick mapped with the same letter. It’s one limitation of this technique, but for the sort of use described here (I set it up the same on every PC at home) it works well.