在不用第三方工具情况下能用批处理来创建快捷方式,真是绝招。如果把代码简单地改一下就可创建快捷方式到桌面上:
| @echo off | | | | set "a=%1" | | set "name=%~nx$a:1%" | | echo [InternetShortcut] >"%userprofile%\桌面\%name%.url" | | echo URL="%a%" >>"%userprofile%\桌面\%name%.url" | | echo IconIndex=19 >>"%userprofile%\桌面\%name%.url" | | echo IconFile=%SystemRoot%\system32\SHELL32.dll >>"%userprofile%\桌面\%name%.url" | | exitCOPY |
再改进一下,快捷方式图标与关联程序相同:
| @echo off | | | | set "a=%1" | | set "name=%~n$a:1%" | | set "ext=%~x$a:1%" | | if "%ext%"=="" goto FOLDER | | if "%ext%"==".bat" goto BAT | | if "%ext%"==".cmd" goto BAT | | for /f "tokens=2 delims==" %%b in ('assoc %ext%') do ( | | for /f "tokens=2 delims==" %%c in ('ftype %%b') do set "d=%%c" | | ) | | set e=%d:~0,-5% | | set f=0 | | | | :URL | | echo [InternetShortcut] >"%userprofile%\桌面\%name%.url" | | echo URL="%a%" >>"%userprofile%\桌面\%name%.url" | | echo IconIndex=%f% >>"%userprofile%\桌面\%name%.url" | | echo IconFile=%e% >>"%userprofile%\桌面\%name%.url" | | exit | | | | :FOLDER | | set e=%SystemRoot%\system32\SHELL32.dll | | set f=3 | | goto URL | | | | :BAT | | set e=%SystemRoot%\system32\SHELL32.dll | | set f=71 | | goto URLCOPY |
[ 本帖最后由 newxso 于 2008-11-30 20:40 编辑 ] |