How To Auto-Launch Apps From USB Sticks In Windows 7


05.10.2011

How To Auto-Launch Apps From USB Sticks In Windows 7

Portability is the word of the hour. These days information can be transferred and carried in so many ways. Most users prefer for this job a simple USB stick because of its size and maneuverability. But you must know that there are multiple usages for this little device that we all learned to love and use. You can store on it a collection of your favorite apps. To go even further there could be even 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. To make it simple it is all up to you.

But the questions is: would it be nice to just walk into a room and sit on any computer and with the help of your USB port to have all your portable apps at your disposal without having to always put the effort to download them? The answer is surely yes.

With the passing of years numerous system administrators managed to get all kind of tricks in order to accomplish various tasks. If I remember well at one point there was an article (sorry, I can’t remember where) about some useful ways people could use Windows Task Scheduler to launch various jobs. Also all over the web there are many articles in which USB apps are presented and explained. That’s why I considered that the time had come for me to write an article covering a few USB auto-launch techniques that administrators have used. If somebody has told you that it is impossible to launch applications from your USB card know that you have spoken to a liar (for those of you who don’t know you can even install Windows 7 from an USB device). Here is the path you need to follow.

In order to make apps auto-launch themselves from an USB device there are a few lines of code you need to create. System administrators have started to use this technique with Windows 2000 and some even earlier. All you need to do is create an autorun.inf file and applications will start from your USB memory the same way they start from CDs. The file doesn’t need to be that complicated and it can be a very simple one. I suggest using the following lines to have a standard model at your disposal:

[autorun]
icon=mypic.ico
open=start-zim.bat
action=Click “OK” to start your apps!

At this point all that you need to have is the icon of the image. The job is auto completed for you and it will start at the second you insert the USB stick in your computer. Any OS like Windows XP for example will pop up a message with the autorun info inside it. Just click the “OK” option and you’re good to go. You can even start a batch job using this method. So, the computer will start all the apps that you want and by doing so offering its user a customized way to open up all of your apps in an automated way that saves a lot of time.

But that was in some ways a limited option because of the pop-up prompt. In my years of experience I have hear that there are even ways to go around and avoid that pop-up. All you need is a bit of tweaking/hacking. I don’t recommend it just because of the vulnerability created in your system. Viruses and other hackers love these “doors” opened this way. In most recent versions of Windows, and I am speaking here about Windows 7, people from Microsoft managed to repair this vulnerability by disabling the USB functionality of autorun.inf (if we can’t fix it, just remove it apparently). In the later updates offered to Windows XP this feature was also disabled for the same security reasons.

Now let’s focus on the main subject of this article. Let’s see how we can launch apps automatically from a simple USB stick. The removal of autorun.inf didn’t mean also the removal of starting applications from an USB device. There are other ways to launch programs in Windows 7 from your USB stick.

I always tend to use a little app named AutoIT which can be found very easily over the internet. This is a very cool tool that offers a scripting language in which you can compile those scripts into exec programs that you also distribute on your PC. If you download it you also get and editor and a convertor software for your needs. Among other things provided by this app there are a lot of scripts created by random people that offer multiple purposes. I will write in the following how a computer can detect when a USB stick has been inserted into its 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

With the help of it a “device change” is recognized and also when a USB stick is present a message should appear. If you go with your imagination further, just think that if there is the possibility to recognize when a stick is present and also launch it, why we couldn’t make an app run. In order to do so, I just took the script above and instead of the MsgBox command I wrote the next line of cod:

Run ("F:SystemAppsimWikiim Desktop Wikistart-zim.cmd")

This line simple detects when an USB stick is inserted and at the same time automatically starts the Zim Wiki app I have on my USB stick that I use to organize and monitor my writing work.

But let’s go with this even a little further. There is a way to auto-launch a program with a simple insertion of an USB stick. And to make things a little more complicated, let’s launch a whole collection of apps. This can be done through a batch job on your USB card called startapps.bat that launches all the programs you want for that particular stick. SImpel write the next line:

START "" F:SystemAppsimWikiim_Desktop_Wikistart-zim.cmd
START "" C:UsersOwnerMUO_STORY_IDEASMUO_STORY_IDEAS.txt
START "" FIREFOX.EXE http://www.makeuseof.com/wp-admin

You are probably wondering what could be the reason of all this. It’s very simple actually. This method will provide with a unique “startapps.bat” script for various USB sticks. It comes very handy if the user has multiple devices with different purposes like school work (you can open class papers at one touch) or something from office where a more detailed action needs to be done. And what happens if let’s say you work as a help desk tech, where it would auto-launch PC support utilities and your favorite tech website (MUO of course).

There is a catch to all of this. The EXE file you have created with this AutoIT script has to be running on every PC that you want the auto-launch to occur on. This happens mainly (and I consider it to be a good thing) because of security reasons from Windows 7 creators. With a simple opening of the AutoIT script above, you can compile and also build the script to create your EXE file. Just put that EXE in the Startup folder of computers you use on a base time. If the script is running, you’ll see the following Icon in the task bar.

The one thing that I consider to be great about this script is the fact there aren’t any prompts at all. With a simple insertion of an ordinary USB stick all applications are at your disposal and are auto-lunching themselves. Give it a go and see how things work for you. If you encounter any problem or just feel there could be a different approach to all f this, be sure to write us in comments or even mail us.

Tags: there, stick, apps, windows, simple, start, also, even, just, script, autolaunch, launch, ways, let’s, very, could, file, work, computer, device, little, make, because, time, applications, write, create, some, about, where