How to Make a AutoRun CD or DVD Using Autorun.inf

In this post we will see how to setup autorun on a CD or Pen drive using Autorun.inf file. If you are planning to create a CD with autorun (launch a file automatically on insertion of disc), this post will be helpful for you. If you are not much familiar with AutoRun, read the following post, to get an idea about autorun feature:  What is AutoRun or AutoPlay and How to Set it?

Now, we see how to make an autorun CD.
We have all the files ready to be written to the CD. But what to do to launch some file, say setup.exe, when you insert the CD. You have to create an Autorun.inf file in the root folder. A file of type .inf is called a setup information file. It is not a hard job. To create Autorun.inf,  just open notepad, type the commands in it (commands are discussed below) save the file with name Autorun.inf (remember to remove .txt from filename before saving). This file should be right in the in CD (you should not place it in any folder inside the CD, if CD Drive is D, then the path of Autorun.inf should be D:\Autorun.inf).

It is not the matter. You should know what should be the contents of the file Autorun.inf. The first line should be:

[autorun]

This is to indicate that this setup information file is intended to setup autorun. In the next lines you can use some commands like open, ShellExecute, Label, Icon etc.  Let us see an example with open, label and icon commands. Before that, I'll show the CD contents.



How to make create burn auorun CD or pen drive autorun.inf autorun autoplay auto run play contents of file [autorun] .inf open open= automatic automatically launch file executable exe install

So, the files are as shown in above picture. Then, my plan is as follows:

  • I want flashplayer.exe to be launched automatically when CD is inserted.
  • I want to set myicon.ico as the Icon of CD Drive.
  • I want to set the CD label as Install Flash
To reach the above goals, the content of Autorun.inf file should be as follows:

[autorun]
Open=flashplayer.exe
Label=Install Flash
Icon=myicon.ico

Here in this example, the files (flashplayer.exe,myicon.ico) are directly in the CD drive. The CD label and Icon has changed after writing the files (including Autorun.inf) to the CD.

change set make cd or DVD label or cd name and CD icon using Autorun.inf file with autorun feature. Windows

Open Command

The open command is used to launch an .exe file. After the '=' symbol following open command, give the relative path to the executable file. In above example we just used the filename (including extension) to specify the file to be opened automatically. It is because the file is in the drive's root directory. Suppose that flashplayer.exe is in a folder flash in the CD, then the open command should be as follows:

[autorun]
Open=flash\flashplayer.exe

Do not use the drive letters in the path. The filename can be followed by optional parameters to the application specified. Parameters are used when the working of application (here flashplayer.exe) depend on the parameters. Here flashplayer.exe  is a setup file and require no parameters.

NB: Avoid space in the filename. Space is used to separate filename from parameters to the executable file.

Only executable files can be launched using open command. You may use ShellExecute command to launch other files, which is explained below.

An example of usage of open command with parameters is as follows:

[autorun]
Open=msiexec.exe /i setup.msi 

In this example, the application Msiexec.exe is opened with parameters /i and setup.msi.
To launch .msi file using Autorun, see this post: How to Launch .msi Files using Autorun from CD.

Label Command

The label command is used to set the CD label (like volume label). The '=' symbol after label command is followed by a text string containing the label. It can contain spaces and should be no longer than 32 characters. The first example is enough.

Icon Command

The icon command is used to set the CD Drive Icon. After the '=' symbol following icon command, give filename (including extension and excluding path) that contain the icon. This icon replaces the standard drive icon in Windows Explorer. The file should be in the same directory of the file specified in open command. The file need not to be a .ico file only. It can be .ico, .bmp, .exe, or .dll file containing an icon. Files of extension .dll, .exe can contain more than one icon. In such cases, you must also specify zero-based index of the icon.

[autorun]
Open=install\setup.exe
icon=setup.exe,0

In above example, the setup.exe file is in a folder named install. The icon is read from the setup.exe. Here the path is not specified. The windows OS always assumes that the file is in the same directory as that of the file specified in open command. The CD drive will get the 1st (index=0) icon from the setup.exe file.

ShellExecute Command

If ShellExecute command is used along with open command, both should specify same file. The main difference between ShellExecute and  open is that open command can launch .executable files only while ShellExecute  command can launch data file also. Data file should be of known file type.

Here is an example.


[autorun]
shellexecute=online_radio.html
icon=myicon.ico
label=Radio

In this example, an .html file (web page) in the root directory is launched using shellexecute command. Known filetypes like html, msi, jpeg, png, txt etc can be launched using shellexecute command. But if you launch .rar file, it will not be convenient in a system which does not have applications installed to open this kind of file. If you specify a file of extension for which there is no associated program installed in a system, it will  ask the user to choose the default application to open the file.

shell\verb

shell\verb helps to add context menu (menu that appears on right clicking on CD drive) entries. Consider an example:

[autorun]
shell\flash=Install &Flash player
shell\flash\command=flashplayer.exe
icon=myicon.ico
label=Radio

In above example A new entry is added to context menu of CD drive. The menu text of the entry will be Install Flash player. And when we click on this context menu item, flashplayer.exe will be launched. Here we use the word flash which is an arbitrary variable. You can use any word. Avoid space. The &  symbol is to specify the key shortcut to the context menu item. Here if you right click on CD drive and press F on keyboard, flashplayer.exe will be launched. The filename following command= should be an executable file. Few more examples:

[autorun]
open=setup.exe
shell\readme=Show &Read me
shell\readme\command=notepad.exe readme.txt
icon=myicon.ico
label=Setup CD

Here shortcut key is R. Notepad is called and readme.txt (filename with path) is passed as parameter to notepad.exe to open it. You need not to specify path of some known application like notepad.exe. There are some applications in C:\Windows directory (where C is the drive where windows is installed) like notepad.exe, explorer.exe, regedit.exe, write.exe or wordpad.exe. You may try applications in system32 folder like xwizard.exe, taskmgr.exe, dvdplay.exe, makecab.exe, msiexec.exe, charmap.exe, Narrator.exe, fontview.exe, iexpress.exe, isoburn.exe, mspaint.exe, cmd.exe, iexpore.exe etc.

Another example:

[autorun]
shell=playradio
shell\playradio=Play &Radio online
shell\playradio\command=iexplore.exe online_radio.html
shell\rm=Show &Read me
shell\rm\command=notepad.exe readme.txt
icon=myicon.ico label=Play radio

Here an extra line shell=playradio is added. The command shell=verb (general form) is used to set this command as default one. That is, this line makes the application specified after 'command=' launched automatically. In short, shell=playradio executes the application iexplore.exe with given parameter automatically. So, an extra OPEN command is not required. Only one of the shell\verb entries can be set this way. That is shell= should not occur in the Autorun.inf more than once.

NB: If you use shell= command in the autorun.inf  file, avoid open command.

No comments :

Post a Comment