USB Autorun? MMMMMmmmm... tasty.

Discuss anything related to portable freeware here.
Post Reply
Message
Author
Erind
Posts: 75
Joined: Thu Jul 13, 2006 7:11 pm

USB Autorun? MMMMMmmmm... tasty.

#1 Post by Erind »

So, I was over at PortableApps.com browsing their forums and BLATANTLY stole this from them. :) And I love it! Granted, it will try to execute the same app each time you plug in any USB Drive, but since I only frequently swap out one drive, this works like a charm!
I use autoplay handlers built into windows xp to autostart Pstart on plugin of the USB. It can be modified to autostart any program and is just a few registry entries.

Basically, you create a new autoplay option in the registry, which you then choose under the autoplay options in the drive properties window. Then you choose your new option and tell it to always use it and from that time on you only have to plug in the drive and it will autostart that program. Below is instructions on how this can be done. I have copied it from the txt file I keep them in to this post:

---------------------------------------------------------------------------------------------------------------------------
-------------------------------------------USB Autoplay Handler------------------------------------------------------------
---------------------------------------------------------------------------------------------------------------------------

*****What is USB Autoplay Handler?*****

This is a way to create a autoplay handler for USB devices within Windows XP. It allows the user to create an autoplay
option for any program residing on a USB Device or other removable drive. I have included the instructions and necessary
registry entries below. Enjoy!

*****Some Problems to Consider, Nothing to Bad though :)*****

So far I have tried this on a number of Windows XP Machines and it works everytime. However, The following needs to be
considered:

1. You do need to have Administrator rights to import the entries to the registry, but After that though it will work
without admin rights.
2. The path the executable will have to be change before you enter it into the registry on a new machine, as the drive
will change. (NOTE: If any one can find an enviromental variable to allow windows to always find the USB Drive,
it would then not need to be changed. I am still looking into it)
3. You must have Autorun enable on the PC for this to work.

Other than the above I see no other problems.

*****Instructions for changing it for any system*****

Below is the registry file you need to create. (Just copy the code in between the Start and End lines)

To make it work for your system and program, follow the below steps:

1. In the second key, change the "Action" Setting, where it says "USB Portable Apps List" to the an action name
such as "Open Firefox".
2. Change the "Provider" Entry to the manufacturer of the program, such as "Firefox Browser".
3. In the third Key, change the "PStart (ISO)" to "(ProviderEntry) ISO", Place what you put in the provider above
in place of the (ProviderEntry). Make sure you put a space and ISO after the entry.
4. In the last key place the path to the executable of the program you want to start.
5. Save the file as a .reg file, and then double click on it to import it to your registry.
6. Plug in your USB drive and then go to "My Computer > USB Drive > Properties" then goto the the "AutoPlay" properties page
click the drop down list and select "Mixed Content" you should see your new entry there.
7. Check the "Select Action to perform" circle and then choose your entry. Choose "Apply" and then "OK" to close.
8. Now log of and back on. This will reload the registry with your new changes.
9. Unplug and then replug in your USB and the program should autostart.
10. Finished!!

:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::Start Registry file::::::::::::::::::::::::::::::::::::::::::

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\AutoplayHandlers\EventHandlers\MixedContentOnArrival]
"USBStart"=""

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\AutoplayHandlers\EventHandlers\ShowPicturesOnArrival]
"USBStart"=""

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\AutoplayHandlers\EventHandlers\PlayMusicFilesOnArrival]
"USBStart"=""

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\AutoplayHandlers\Handlers\USBStart]
"Action"="USB Portable App List Start"
"DefaultIcon"=hex(2):25,00,53,00,79,00,73,00,74,00,65,00,6d,00,52,00,6f,00,6f,\
00,74,00,25,00,5c,00,73,00,79,00,73,00,74,00,65,00,6d,00,33,00,32,00,5c,00,\
53,00,48,00,45,00,4c,00,4c,00,33,00,32,00,2e,00,64,00,6c,00,6c,00,2c,00,2d,\
00,38,00,00,00
"InvokeProgID"="USBStart"
"InvokeVerb"="open"
"Provider"="PStart"

[HKEY_CLASSES_ROOT\USBStart]
@="PStart (ISO)"

[HKEY_CLASSES_ROOT\USBStart\DefaultIcon]
@="F:\\Apps\\PStart\\pstart.exe,1"

[HKEY_CLASSES_ROOT\USBStart\shell]

[HKEY_CLASSES_ROOT\USBStart\shell\open]

[HKEY_CLASSES_ROOT\USBStart\shell\open\command]
@="F:\\Apps\\PStart\\pstart.exe"

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::End of Registry File::::::::::::::::::::::::::::::::::::::::

****Final Thoughts****

It is possible to change the icon of the autoplay handler by changing the "DefaultIcon" entry in the second Key. I have it
set to use the USB icon in the Shell32 file in the windows folder, as 99% change it will be on any Windows XP system. If you
want to use another Icon, then chance the entry to a path to the icon. Just make sure you change that path as you would the
path the the executable on a new machine.

****************************************************************************************************************************

Created By Deuce199
Using Windows XP Professional
Tested on Windows XP Professional Systems
December 15, 2005

Any questions just ask.

Deuce

stumpii
Posts: 36
Joined: Sun Feb 05, 2006 6:37 pm
Location: Texas, USA

#2 Post by stumpii »

The same can be achieved by using TweakUI. It is a bit easier and allows "%L" to be entered into the path to represent the root of the drive being inserted.

I have written a real small portable program that can sit in the root of the USB drive that can be run as the default program in TweakUI or the reg hack above. This prog just reads the 'open' entry in the Autorun.inf file and executes it. This way each USB drive can be made to run a different file. You can download it below. Have just written it, so there are no docs atm. Remember that you need to set up Autorun.inf correctly in the root.

http://thefoolonthehill.net/Autorun.htm

Edit: Changed link.
Last edited by stumpii on Mon Nov 27, 2006 10:33 am, edited 1 time in total.

Erind
Posts: 75
Joined: Thu Jul 13, 2006 7:11 pm

#3 Post by Erind »

First, the program you wrote fails to run if the autorun.inf isn't in the root of IT'S hard drive, making it impossible to use on a removable. :) Also, I enabled autorun on removable drives using TweakUI, I've HAD an autorun.inf file set up forever and a day, my problem is that XP still scans the drive (HDD in an external case) and then provides all of the Media options (play movies, open folder, view slideshow, etc) because I've got all of those types of files on the drive. The TOP option is the program listed in the autorun.inf which it WILL NOT EXECUTE AUTOMATICALLY. It brings me the prompt where all I have to do is hit enter, but that's not automatically.

It's screwed up, Microsoft is bass ackwards. They let CDs coming from random people execute autorun.inf, but not your own, custom built, hard drive.

stumpii
Posts: 36
Joined: Sun Feb 05, 2006 6:37 pm
Location: Texas, USA

#4 Post by stumpii »

Erind wrote:First, the program you wrote fails to run if the autorun.inf isn't in the root of IT'S hard drive, making it impossible to use on a removable. :) Also, I enabled autorun on removable drives using TweakUI, I've HAD an autorun.inf file set up forever and a day, my problem is that XP still scans the drive (HDD in an external case) and then provides all of the Media options (play movies, open folder, view slideshow, etc) because I've got all of those types of files on the drive. The TOP option is the program listed in the autorun.inf which it WILL NOT EXECUTE AUTOMATICALLY. It brings me the prompt where all I have to do is hit enter, but that's not automatically.

It's screwed up, Microsoft is bass ackwards. They let CDs coming from random people execute autorun.inf, but not your own, custom built, hard drive.
My bad! I have fixed the program and modified it so that it creates all the registry entries (no need to use TweakUI).

Here are the steps with this new program:

1. Download and unzip 'Autorun.exe' somewhere on your local hard disk (not a removable drive).
2. Run the program. This will setup the registry stuff. If you move the program, just run it again.
3. Plug in your USB drive, right click on it in Explorer and click 'Properties' then click on the 'AutoPlay' tab.
4. Click the drop down list and select "Mixed Content". You should see 'Autorun USB Drive' there.
5. Check the "Select Action to perform" option and then select 'Autorun USB drive'. Click "OK" to close.
6. Make sure that there is an 'Autorun.inf' on the USB drive. Confirm that the file contains an 'open=' line and that it refers to a program on the USB drive.
7. Unplug and then replug in your USB and the program should autostart.

The program is available here:

http://thefoolonthehill.net/Autorun.htm

Edit: Changed link.
Last edited by stumpii on Mon Nov 27, 2006 10:33 am, edited 1 time in total.

Darkbee
Posts: 291
Joined: Mon Feb 06, 2006 8:35 am
Contact:

#5 Post by Darkbee »

Microsoft Autoplay is the spawn of the devil. :evil:

stumpii
Posts: 36
Joined: Sun Feb 05, 2006 6:37 pm
Location: Texas, USA

#6 Post by stumpii »

I have finished a web page for the program if anyone is interested:

http://thefoolonthehill.net/Autorun.htm

User avatar
Andrew Lee
Posts: 3061
Joined: Sat Feb 04, 2006 9:19 am
Contact:

#7 Post by Andrew Lee »

I added this to the FAQ page under the question "How do I enable autorun on my USB drive ..."

Post Reply