Start program when USB-memory is inserted?

This is a discussion on Start program when USB-memory is inserted? within the C Programming forums, part of the General Programming Boards category; Hello! I am writing a program that is supposed to be stored on a USB-memory. When the USB-memory is inserted ...

  1. #1
    Registered User
    Join Date
    Nov 2006
    Posts
    9

    Start program when USB-memory is inserted?

    Hello!
    I am writing a program that is supposed to be stored on a USB-memory.
    When the USB-memory is inserted into the computer I want the program to start by it self.
    Is this possible?
    How can I solve it, how do I get that event?

    Please point me in the right direction.

    Many thanks in advance!

    Marcux

  2. #2
    verbose cat
    Join Date
    Jun 2003
    Posts
    209
    That would be an OS dependant issue. Windows for example can be set to read the Autorun.ini on a CD when you insert it, and the Autorun will identify which program to automatically execute on the CD.

    I don't know if Windows will do the same for a USB device, and I have no idea about Linux/MacOS. Try Google'ing for more info on Autorun.
    abachler: "A great programmer never stops optimizing a piece of code until it consists of nothing but preprocessor directives and comments "

  3. #3
    Registered User guesst's Avatar
    Join Date
    Feb 2008
    Location
    Lehi, UT
    Posts
    179
    Yeah it will. In windows make an autorun.inf file in notepad and write the correct line. I'm too lazy right now to look up what line you need to type, but a google search should do the trick.
    Type-ins are back! Visit Cymon's Games at http://www.cymonsgames.com for a new game every week!

  4. #4
    Registered User
    Join Date
    Jun 2005
    Posts
    6,536
    This is not a C issue; it's a windows OS issue (I assume). I'm not sure offhand if the autorun technique works for USB sticks (never had to try) but it does work for CDs and DVDs.

    The basic format of the autorun.inf file is a straight text file something like;

    PHP Code:
    [autorun]
          
    open=yourprog.exe
          icon
    =yourprog.ico 
    There are a few more advanced options as well, but that's the basics.

    Keep in mind, however, that windows can be configured by the user so it does not attempt to autorun a new volume, so it pays to provide alternatives (eg obviously named installation program that the user can run). Personally, I always disable autorun.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Client-server system with input from separate program
    By robot-ic in forum Networking/Device Communication
    Replies: 3
    Last Post: 01-16-2009, 03:30 PM
  2. xor linked list
    By adramalech in forum C Programming
    Replies: 23
    Last Post: 10-14-2008, 11:13 AM
  3. Using extended memory to store program data
    By Robby in forum C Programming
    Replies: 1
    Last Post: 01-11-2005, 08:19 AM
  4. Problem with usb Flash memory
    By khpuce in forum Tech Board
    Replies: 6
    Last Post: 02-26-2004, 08:54 AM
  5. operator overloading and dynamic memory program
    By jlmac2001 in forum C++ Programming
    Replies: 3
    Last Post: 04-07-2003, 12:51 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21