autorun.inf 是一个 Windows 系统中的文件,用于在启动时自动运行指定的程序或脚本。它通常用于创建自动运行的 USB 驱动器或可启动介质(如 CD/DVD)。
一、autorun.inf 的基本格式
[autorun]
open=yourprogram.exe
shell=launch
icon=icon.ico
二、各字段解释
| 字段 | 说明 |
|---|---|
[autorun] |
文件的起始部分 |
open= |
指定启动时运行的程序(路径) |
shell= |
指定启动时执行的命令(如 launch 表示执行 open 的程序) |
icon= |
指定图标(可选) |
三、常见用法示例
示例 1:自动运行 notepad.exe
[autorun]
open=notepad.exe
shell=launch
icon=notepad.ico
示例 2:自动运行脚本(如 script.bat)
[autorun]
open=script.bat
shell=launch
icon=script.ico
示例 3:自动运行程序并显示图标
[autorun]
open=yourprogram.exe
shell=launch
icon=yourprogram.ico
四、创建 autorun.inf 文件的步骤
- 创建一个文本文件,命名为
autorun.inf。 - 在文件中输入上面的格式,例如:
[autorun]
open=notepad.exe
shell=launch
icon=notepad.ico
- 保存文件,文件类型选择
All Files,确保保存为.inf格式。
五、注意事项
- 需要管理员权限:在 Windows 中,
autorun.inf需要管理员权限才能生效。 - 驱动器必须是可启动介质:
autorun.inf通常用于 USB 驱动器或 CD/DVD。 - 图标文件:
icon.ico是可选的,如果未指定,系统会使用默认图标。
六、常见问题
- 无法自动运行:可能是文件路径错误、权限不足、或驱动器未正确设置为可启动介质。
- 图标不显示:可能是图标文件路径错误,或未在系统中注册。
七、扩展功能(可选)
- 添加启动菜单:使用
menu或shell指令添加菜单项。 - 添加启动参数:通过
open后面添加参数(如open=yourprogram.exe /arg1)。
如果你有具体的程序或脚本想要自动运行,可以告诉我,我可以帮你生成对应的 autorun.inf 文件。