【批处理】创建快捷方式

方法1
@echo off
set "exe=%~dp0proe.exe"
set "name=新创建的快捷方式"
set m="%ALLUSERSPROFILE%\桌面\%name%.url"
echo [InternetShortcut]>%m%
echo URL="%exe%">>%m%
echo IconIndex=0>>%m%
echo IconFile=%name%>>%m%

方法2
@echo off
echo Path=%~dp0>test.txt
echo Overwrite=^2>>test.txt
echo Shortcut=D, "proe.exe", "\", "快捷方式描述", "快捷方式 proe.exe">>test.txt
start /wait winrar.exe a -r -ep1 -m1 -sfx -ztest.txt test.exe "proe.exe"
test.exe /s
del test.*

方法3
@echo off
if exist tmp.vbs del tmp.vbs /q
>tmp.vbs echo Set WS=WScript.CreateObject("WScript.Shell")
>>tmp.vbs echo Set Shortcut=WS.CreateShortCut("%ALLUSERSPROFILE%\桌面\proe.exe.lnk")
>>tmp.vbs echo Shortcut.TargetPath=WS.CurrentDirectory^&"\proe.exe"
>>tmp.vbs echo Shortcut.WorkingDirectory = "%~dp0"
>>tmp.vbs echo Shortcut.Save
"%SystemRoot%\System32\CScript.exe" //nologo tmp.vbs &&del tmp.vbs

补充(你增加点东西使得快捷方式的起始位置改成“D:\”)
@echo off
if exist tmp.vbs del tmp.vbs /q
>tmp.vbs echo Set WS=WScript.CreateObject("WScript.Shell")
>>tmp.vbs echo Set Shortcut=WS.CreateShortCut("%ALLUSERSPROFILE%\桌面\proe.exe.lnk")
>>tmp.vbs echo Shortcut.TargetPath=WS.CurrentDirectory^&"\proe.exe"
>>tmp.vbs echo Shortcut.WorkingDirectory = D:\"
>>tmp.vbs echo Shortcut.Save
"%SystemRoot%\System32\CScript.exe" //nologo tmp.vbs &&del tmp.vbs

你可能感兴趣的:(批处理)