How to create an autorun?

4

I made a program through Visual Studio and I'm trying to create an autorun to run it, however, the program executable is in \programa\programa\bin\Debug\programa.exe and autorun should be in the root folder of the CD or image.

This is the problem, how could I make autorun work, since the executable is in another folder?

    
asked by anonymous 04.03.2014 / 17:56

2 answers

5

Create an autorun.inf in the CD Root Folder containing content similar to this:

[autorun]
open=programa\programa\bin\Debug\programa.exe
icon=Autorun.ico

Explanation:

  • "open=" shows Windows which command to execute.
  • "icon=" shows Windows which icon will be used to render the media (CD, DVD, or Pen Drive) in My Computer or Windows Explorer.

The first line "[autorun]" is only to identify that it is an autorun file and should be specified in all created autorun.inf files.

Source: link

    
05.03.2014 / 15:28
6

Answering a little more than asked, I'll point out some options you have when using the autorun.inf file :

Key Attributes

  • action=texto Optional: auto-run item text, both in the context menu and in the auto-run media window.

  • icon=caminho icon path to be used to represent media

    You can reference an icon within an icon, executable, or dll by placing a comma + icon index inside the file:

    app\ConsoleApplication.exe,0
  • label=texto media title that appears in Explorer

  • open=caminho path to automatic execution

Attributes for adding items to the context menu

  • shell=nome_comando_primario indicates which is the primary menu, which appears in bold in the context menu, and will be used in double click

  • shell\nome_comando=texto represents the title of the menu_name command_name ... there may be several titles for different_command_name:

    shell\comandoA=Título comando A
    shell\comandoB=Título comando B
  • shell\nome_comando\command=caminho path of the executable that should be triggered by clicking the specific command. There should be one for each specified command title:

    shell\comandoA\command=app\ConsoleApplication.exe
    shell\comandoB\command=notepad.exe arquivos/leiame.txt

Map of parts of the Autorun.inf file

Below is a map showing where the texts placed in the Autorun.inf file should appear, as well as the relationship between the properties. I used colors to indicate related elements in various parts.

Completeexample

[autorun]action=ExecutarConsoleApplication.exe(action)open=app\ConsoleApplication.exe%0icon=app\ConsoleApplication.exe,0label=TítulodoCD(label)shell=iniciarshell\iniciar=Lançaraaplicação(shell\iniciar)shell\iniciar\command=app\ConsoleApplication.exe%0shell\leiame=&Leroaqruivoleiame.txt(shell\leiame)shell\leiame\command=notepad.exearquivos/leiame.txt

Application

usingSystem;namespaceConsoleApplication{classProgram{staticvoidMain(string[]args){Console.WriteLine(string.Join(" ", args));
            Console.WriteLine("Olá mundo!");
            Console.ReadKey();
        }
    }
}

Adding an icon to your app

Go to the properties of your executable project in the Application tab, then just select an icon file:

Reference

Autorun.inf Entries (MSDN)

link

    
05.03.2014 / 19:43