0

I have a C# .exe program that I wish to run every time when USB flash drive is inserted that opens welcome screen.

I know about autorun.inf files and similar stuff that show option in autorun "menu" but I need to start program automatically (plug and play).

How can I achieve this without using any additional programs that user needs to install in it's computer.

user2880783
  • 145
  • 6
  • 18
  • In autourn.inf have you tried using `open=*path to exe*`? – d3dave May 06 '14 at 08:57
  • autorun will work only for systems older than windows 7. For Windows 7 + you will have to emulate a cd rom – Milan Halada May 06 '14 at 08:59
  • also autorun shows option in autorun menu that user needs to select but I need plug and play system that starts program automatically as I already mentioned in question. Link that @dash showed as duplicate uses autorun.inf that I don't need... – user2880783 May 06 '14 at 09:04
  • @user2880783 The other question also has an answer that demonstrates how to do this with a 3rd party piece of software, if that helps; http://stackoverflow.com/a/14873273/1073107 – dash May 06 '14 at 10:50

2 Answers2

0

How can I achieve this without using any additional programs that user needs to install in it'c computer.

You can't (anymore) as this would be a BIG security vulnerability. Imagine every malicious piece of software could do this...

The autorun.inf solution is the best you can do.

Christoph Fink
  • 22,727
  • 9
  • 68
  • 113
  • I figured as much because of security. My idea was that I run welcome screen and in the background monitor if user is copying another program and limit number of copies. Is there any way to copy protect my usb? – user2880783 May 06 '14 at 09:26
  • `Is there any way to copy protect my usb?` Not really. If he can read it once, he can read it multiple times (or copy it once to local and then multiple times from there). You can only try to lock the program so it only runs from the USB. We did something here using some different techniques, but really secure are non of them... – Christoph Fink May 06 '14 at 09:32
0

Programs can't start automatically from a USB Mass Storage device as they are meant to store data only.

From here (SO)

USB mass storage devices do not perform Autorun on Windows. You need to enumerate as a USB CD-ROM device in order to support autorun.

If you have a U3 capable USB drive, you can often replace the U3 data with your own CD image.

If this is a custom USB device, you will need to implement a composite device with the Mass Storage and USB CD-ROM device (or just the CD-ROM if you don't want to supporting writing).

Community
  • 1
  • 1
Arctic Vowel
  • 1,492
  • 1
  • 22
  • 34