First, create a text document under the root directory of the USB flash drive.
Then rename it autorun. inf (Be sure to change the suffix)
Enter [Autorun] // indicates that the autorun part starts and must be entered.
Icon = C. ICO // give the USB flash drive a personalized drive letter icon C. ICO (the icon name can be changed for C. ico)
Then place an icon file named C. ICO in the root directory of the USB flash drive.
You can use
Attrib + S + H l:/C. ICO (L is the name of the USB flash drive). Set the file attribute to system file hidden file.
Attrib + S + H l:/autorun. inf
Hide these two files.
The following describes how to use Autorun.
We already know that you can use container run. INF to specify the icon automatically loaded by the CD and the running file. In fact, Autorun. the usefulness of INF can be greater. The following describes Autorun in detail. INF application.
Learn about autorun. inf
What is Autorun. INF file, strictly speaking, it is a text file that must be stored in a certain format under the root directory of the drive. It is composed of one or more "sections, each "section" must start with the section name. The section name must be enclosed in brackets [], and the section name is the command in this section.
Autorun. inf supports three sections, including [Autorun], [Autorun. Alpha], and [deviceinstall]. Only [Autorun] must exist.
Instance application
Now let's take an instance to learn in detail what the autorun. inf file has to offer.
(1) Automatic Operation
The automatic running is exposed in the previous article, that is, using the open command. Note that the file specified by "open =" must be an executable file, such as COM, EXE, and bat; if the specified file is not in the root directory, You need to specify its path, for example, open = soft/1.bat. this indicates 1. BAT file.
TIPS: if the file to be run is not com, EXE, or bat, it doesn't matter. We can compile a BAT file manually, add the path and file name of the file to be opened to bat.
(2) custom disc icons
In the autorun section, there is another interesting command line, which is the icon. Generally, the specified icon file can be in ICO and BMP formats, of course, it can also be an EXE and DLL files containing ICON resources. If the EXE and DLL files contain multiple Icon files, you must specify the icon index number you want to use, note that the icon index number starts from 0, for example, "icon = icon. DLL, 1 ", it indicates the icon will be used. the second icon in the DLL file.
Tip: the icon can be used not only on the CD, but also in the autorun. inf file in the root directory of the hard disk.
(3) custom volume label
Although generally, you can set the disc flags in the CD recording software, if you want to bulk burn the files, it will be very troublesome. It is better to use command-defined shortcuts.
The label command is used to define the volume label. Its syntax is the same as that of open and icon.
(4) Add a shortcut menu
When we right-click the burned disc, we often find an automatic playback option in the right-click menu. In fact, this mainly uses Autorun. in INF, you can add other menu commands as needed.
The format for adding other menu commands is "shell <menu command name> command = <file to be executed>". For example, we have compiled a file with the following content:
[Autorun]
Shell/Open notepad/commandemedinotepad.exe
In this way, when we burn the file into the disc, right-click the disc and a "Open Notepad" command will appear in the pop-up menu.
(5) change the default operation
In general, the default double-click operation of the application autorun. inf disc is mostly automatic playback, that is, the file operations after open. In fact, we can also change this situation, which is also accomplished using shell commands.
Let's take a look at a typical double-click installation example:
[Autorun]
Shell/Setup/command = soft/setup.exe
Shell = setup
To understand this statement, we can look at it from the bottom up. When we double-click the disc, the last shell = setup statement will be called because the sentence is set, when you double-click it, the corresponding shell, setup, and commandcommands will be searched for as commands, and the operations will be converted into the setup.exe file in the softfile folder under the execution directory.
Shell/1 = days old
Shell/1/command/mongonotepad.exe OK .txt
[Autorun]
Open = Regedit/s share. Reg // Add the/S parameter to ensure that no information is displayed during import.
Here we mainly introduce the application of the autorun section content, and for Autorun. alpha is rarely used, while deviceinstall can only be used in Windows XP. It can be used to specify subdirectories for recursive search in the hardware wizard.
Theoretical Basis
Friends who often use CDs know that many CDs run automatically when they are put into the optical drive. How do they do this? The CD will be automatically executed when it is put into the optical drive, mainly relying on two files, one is the autorun. inf file on the CD, and the other is one of the system files of the operating system itself, cdsealing. VxD. Cdsealing. VxD will detect whether there is any action in the optical drive at any time. If so, you can find the autorun. inf file under the root directory of the optical drive. If the autorun. inf file exists, execute the preset program in it.
Autorun. INF not only allows the CD to run programs automatically, but also allows the hard disk to run programs automatically. The method is very simple. Open notepad, right-click the file, and select "RENAME" in the pop-up menu ", rename it Autorun. INF, in autorun. type the following content in INF:
[Autorun] // indicates that the autorun part starts and must be entered
Icon = C:/C. ICO // a personalized drive letter icon for drive C. ICO
Open = C:/1.exe // specifies the region and name of the program. Here, 1.exe is under the C drive.
Hosts file!
The "[Autorun]" line must be in a fixed format. The "icon" line corresponds to the icon file, "C:/C. ICO "is the icon file path and file name. You can change it to the path and file name of your image file when entering it. In addition, ". ICO is the extension of the icon file. If you do not have such files on hand, you can use ACDSee to convert the software in other formats to the ICO format, or find a file with the suffix BMP, rename it to the ICO file.
The "open" line specifies the file to be automatically run and its drive letter and path. Note that if the hard disk and directory you want to change do not have an automatic playback file, you should delete the "open" line, otherwise, the hard disk cannot be opened because the automatic playback file cannot be found. You can only right-click the drive letter and select "open" in the pop-up menu.
I believe that after learning this article, you will surely be able to broaden your horizons. In fact, in addition to the introduction in this article, there are many wonderful applications waiting for you to explore. You need to know that learning is the door for masters to learn.