AutoRun a File from a USB Drive

When you insert a USB drive into your PC, you will be prompted to open the folder. Alternatively, you can specify for the user to be presented with different options. Say, for instance a user inserts a USB drive and you want the user to be prompted with a message that says “Run this application”, and once the user clicks they will run a file that you have specified. To perform this functionality, you need to create a new file called autorun.inf. To do this you’ll have to open up a simple text editor such as notepad and add the following code:

 
[autorun]
icon=iconfile.ico
open=file.exe
label=The text label of the drive
action=Run... This application

You will obviously insert your own filenames respectively in place of ‘iconfile.ico, file.exe, … etc…’

Now save this file to the root directory of your USB drive and save the filename as “autorun.inf”.

When the USB drive is inserted you will receive a pop-up that prompts the user if they would like to ‘Run… This application’ or whatever text you enter as your action. Unfortunately, this autorun feature may only work on PC machines.

If you instead wish to execute an html file the following code will be used instead:

 
[autorun]
icon=iconfile.ico
ShellExecute=file_name.html
label=The text label of the drive
action=Run... This application