How to create an autorun?

Asked

Viewed 2,520 times

4

I made a program by Visual Studio and I’m trying to create an autorun to run it, however, the executable of the program 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 I could make autorun work, since the executable is in another folder?

  • That way \programa\programa\bin\Debug\programa.exe is inside the CD?

  • @bfavaretto, yes.

  • 1

    already tried: open=program bin Debug program program.exe ?

  • @winged, already, but gave problem, said that windows cannot open this type of file.

  • @Patrick made sure to use the relative path?

  • Ah, I got it, I was putting a bar before the road... \programa\programa\bin\Debug\programa.exe

  • @Patrick consider adding an answer to your question.

  • 2

    Note that current versions of Windows only respect Auto Run for optical media. Autorun in HD or USB stick will be solemnly ignored.

Show 3 more comments

2 answers

6

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

Main attributes

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

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

    It is possible to reference an icon inside an icon pacode, executable or dll by placing a comma + the index of the icon 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 command name_menu option... there may be several titles for commandname_`s:

    shell\comandoA=Título comando A
    shell\comandoB=Título comando B
  • shell\nome_comando\command=caminho path of the executable that must be triggered by clicking on the specific command. There must 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 archive

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 the related elements in various parts.

Mapa de onde os textos devem sair

Full example

[autorun]
action=Executar ConsoleApplication.exe (action)
open=app\ConsoleApplication.exe %0
icon=app\ConsoleApplication.exe,0
label=Título do CD (label)

shell=iniciar

shell\iniciar=Lançar a aplicação (shell\iniciar)
shell\iniciar\command=app\ConsoleApplication.exe %0

shell\leiame=&Ler o aqruivo leiame.txt (shell\leiame)
shell\leiame\command=notepad.exe arquivos/leiame.txt

Applying

using System;
namespace ConsoleApplication
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine(string.Join(" ", args));
            Console.WriteLine("Olá mundo!");
            Console.ReadKey();
        }
    }
}

Adding an icon to your application

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

Onde adicionar ícone na aplicação

Reference

Autorun.inf Entries (MSDN)

http://en.wikipedia.org/wiki/Autorun.inf

5


Create a autorun.inf in the Root folder of the CD containing content similar to this:

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

Explanation:

  • "open=" shows Windows the command that should be run.
  • "icon=" shows Windows which icon will be used to repress the media (CD, DVD or Pen Drive) on My Computer or Windows Explorer.

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

Source: http://www.oficinadanet.com.br/artigo/1077/criando_um_arquivo_autorun.inf

Browser other questions tagged

You are not signed in. Login or sign up in order to post.