批处理创建快捷方式【简单好用详解】

好久没来了,发个有用的东西——批处理创建快捷方式。非我原创,这里整理一下,希望对大家有用。

一、批处理生成快捷方式:
1、可以直接生成:
引用:
echo [InternetShortcut]>>"%USERPROFILE%\桌面\BatMPlayer.url"
echo URL="C:\BatMPlayer\BatMPlayer.bat">>"%USERPROFILE%\桌面\BatMPlayer.url"
echo IconIndex=99>>"%USERPROFILE%\桌面\BatMPlayer.url"
echo IconFile=%SystemRoot%\system32\SHELL32.dll>>"%USERPROFILE%\桌面\BatMPlayer.url"
2、也可以先设置变量:
复制内容到剪贴板
代码:

@echo off
set "path=C:\BatMPlayer\BatMPlayer.bat"
set "name=我的BatMPlayer"
set m="%USERPROFILE%\桌面\%name%.url"
echo [InternetShortcut] >>%m%
echo URL="%path%" >>%m%
echo IconIndex=10 >>%m%
echo IconFile=C:\windows\system32\shell32.dll >>%m%
pause
二、查看与解释
1、生成的快捷方式是一个url链接,用记事本打开,得到以下内容:
引用:

[InternetShortcut]
URL="C:\BatMPlayer\BatMPlayer.bat"
IconIndex=17
IconFile=C:\WINDOWS\system32\SHELL32.dll
2、以下是快捷方式内容的解释:
引用:


[InternetShortcut]         ;快捷方式。
URL="C:\BatMPlayer\BatMPlayer.bat"          ;快捷方式的程序路径。
IconIndex=99         ;快捷方式使用的图标的顺序号(此处为系统文件中的图标的顺序,位于以下的IconFile文件夹中,具体查看第三部分的《Shell32.Dll 图标资源对照表》)。
IconFile=%SystemRoot%\system32\SHELL32.dll         ;快捷方式图标的位置(此处为系统文件路径,常见系统快捷方式的图标存放位置)。
"%USERPROFILE%\桌面\BatMPlayer.url"        ; 快捷方式创建位置(此处为桌面),注意双引号和后缀名。
三、Windows系统Shell32.Dll 图标资源对照表
引用:
Windows系统Shell32.Dll 图标资源对照表Shell32.Dll 图标资源对照表