1. Home
  2. Hardware
  3. How to autorun programs from usb flash drive and add custom icons

How To Autorun Programs From USB Flash Drive And Add Custom Icons

Do you want that a certain program should run when you insert your USB flash drive? Or do you want to add a custom icon for your flash drive? If the answer to any of the question is yes, then you have come to the right place.

It is possible to auto run the programs and applications from your removable USB flash drive like the autorun feature in CD/DVD drives. The autorun.inf file is the key to getting your USB drive to perform certain actions automatically and customize it’s look in My Computer. The purpose of this article is to shed some light on how this can be done.

Note: Autorun feature does not work in Windows 7 any more, Microsoft has disabled it due to security reasons. But this feature works fine in Windows Vista, Windows XP, and older OS.

Basic Autorun.inf Structure

The autorun.inf file is a simple text file that can be opened up in any text editor (e.g. notepad). It always starts with a section header of:

[autorun]

Below this header is a list of different options. Each of these options is in the following format:

option=value

autorun

Setting Up AutoPlay Options

Autoplay allows you to set up what file is run when the USB drive is plugged into the computer. There are two options that work in concurrence with AutoPlay. The first is open which specifies the program that you can run automatically with AutoPlay. So, if we wanted to run a program called MyProgram.exe, you would add the this to your autorun.inf file:

open=MyProgram.exe

The second option that we add is the message the user is prompted with. To set this, we use the action option.

action=MyProgram Open Program

exe

When your autorun file is done, save it as autorun.inf. Once the autorun.inf file is saved, the flash drive autoplay will look something like this:

myprogram

Customize USB Flash Drive’s Icon

To create a custom icon for your USB drive, use the icon option. Set it to the name of the icon file.

For example, if you had an icon on the root of the USB drive called sun.ico and you wanted this to be the icon that showed up for the USB drive, you would enter:

icon=sun.ico

You can also use some other application’s icon by specifying

icon=Photo.exe

This is valid as long as Photo.exe is available on the root of the USB drive.

Label Your Flash Drive

If you want your USB drive to display a specific name other than the drive label created when it was formatted, then use the label option. For example, if I wanted to call my drive Asad Drive, I would add this to my autorun.inf file:

label=Asad Drive

label

Now, when you look at your USB drive in My Computer, it will say Asad Drive by the drive letter.

Autorun Files or Web Addresses

If you wanted to view a file on your USB drive in the default application instead of running a program on the drive, you can substitute the open option for the shellexecute option. For e.g

shellexecute=Readme.txt

readme

if you wanted to open up a website www.google.com in the default web browser, you could use the following:

shellexecute=https://www.google.com

readmeweb

Now start customizing your USB drive now. Don’t forget to leave a comment. 🙂

39 Comments

  1. Nice nest site for dominators.
    and the ownager nagibators velotrilo frudiators
    srikoesa ad bikrolpaser.
    nice best dest

  2. is there anyway of removing preset options or by using the inf file stopping the autoplay coming up and just running the program? :

  3. This is a note to Promo USB Developers: It appears that the autorun.inf file is useless in computers running Win XP SP3 or higher. Recent Microsoft updates have kept the autoplay feature, but disabled the autorun feature in XP SP3 and Vista. It is also set this way by default in Windows 7.

    If the user is motivated to do so, there are work-arounds. However, promotional USB developers must keep this in mind as a statistically large portion of users will no longer be able to use their USB drives as effectively.

    I am putting this here so that it may save you time trying to find a solution when this happens to you.

    Hope this helps.

    This was originally posted on my tech blog Priceless Geek. I will also update this blog if I find a valid solution other than ensuring the root directory of your USB only contains a file that say CLICKME.

    The Microsoft KB article that discuss it is here: http://support.microsoft.com/kb/971029

  4. Hi! And Help!
    Thanks for the tips. Need help with….
    I can launch the program OK but cannot get my PDF file to open –
    the code that works is:
    [autorun]
    open=acrobat.exe
    action acrobat open program

    But what/where do I add to get the filename.pdf to open right up?
    Tried the shellexecute – nothing.
    Help! 🙂

    Thanks!

  5. Not a techo – two questions – where do I save auto.inf file to AND am I correct in assuming that if someone puts flashdrive in which also has an autorun program then it will automatically run – if this is the case can I change my autorun program’s name to something like zzxx3426g.exe and will it still run?

  6. I want to auto-run a file, without clicking on anything (I want it to run as soon as I plug in the flash drive). It isn’t “auto”-anything if you have to click on it.
    How would I go about doing this?
    Instructions, links, anything will work.

  7. But if i want to open an .exe WITHOUT any clicks or confirmation from a pop-up window when i insert my USB stick? what should i do? that text should i write in [autorun]?… just like from a CD (from exemple Nvidia CD drive installation that opens setup.exe).

  8. is there a way u can password prtecet ur drive so it can not be formated so like it has to ask for a password, i havea good usb encrpyer but i can still format the drive is the any way i can stop this?? becase they can erase the drive and use it there self, and is there a way u have have more then one Autorun.inf

  9. Excellent instructions for doing this — thank you very much for explaining it so simply and clearly.

    Take care,
    Erredmek

  10. Is there any way to force it to run a program as soon as you plug in the drive, instead of having to click on it to run it? I want to duplicate MouseJiggler, and it would just be that much easier if it started on it’s own.

  11. Actually, bob sagget, it does work. I did it myself. Are you sure you typed everything in correctly using NOTEPAD and saved it as “autorun.inf”?

  12. Is there a way to Run the Presentation(ppt) in full screen, directly when the USB is connected. Without any button clicks.
    Thanks

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.