Labels

English (1) Entertainment (1) Home Work (3) Kids (1) Networking (5) Pakistan (2) QA (30)

Tuesday, July 28, 2009

Tweaking AutoPlay

Q.

I was wondering if there is a way similar to the Windows XP AutoPlay feature for CD/DVD drives that lets you automatically run a particular program from a USB flash drive every time it is connected to the PC.

A.

While the Windows AutoPlay capabilities are by default restricted to CD/DVD drives and fixed disk drives, the easiest way to add autorun functionality to a USB flash drive is to use an 'autorun.inf text file placed in the root folder of that drive. For instance, if you wish to run a certain program called 'sample.exe' from the root directory automatically and prompt the user with a message, then you need to add the following lines to your autorun.inf file:

[autorun] open=sample.exe action=Run sample program

Moreover, using this file, you can even customise the context menu that appears when you right-click the USB flash drive. For example, if you wish to display an additional option called "Run the player" and associate it with an application called 'player.exe' located in the root directory, add the following lines under the ones already given above:

shell\X=Run the player shell\X\commandsplayer.exe

Here, 'X' stands for any action that is to be performed. You may rename it as per your requirements.

No comments:

Post a Comment