简介
一个创建某个文件到桌面快捷方式的BAT批处理.
代码
@echo off
::设置程序或文件的完整路径(必选)
set Program=D:\Program Files (x86)\格式工厂.4.2.0\FormatFactory.exe
::设置快捷方式名称(必选)
set LnkName=格式工厂v4.2.0
::设置程序的工作路径,一般为程序主目录,此项若留空,脚本将自行分析路径
set WorkDir=
::设置快捷方式显示的说明(可选)
set Desc=格式工厂v4.2.0
if not defined WorkDir call:GetWorkDir "%Program%"
(echo Set WshShell=CreateObject("WScript.Shell"^)
echo strDesKtop=WshShell.SPEcialFolders("DesKtop"^)
echo Set oShellLink=WshShell.CreateShortcut(strDesKtop^&"\%LnkName%.lnk"^)
echo oShellLink.TargetPath="%Program%"
echo oShellLink.WorkingDirectory="%WorkDir%"
echo oShellLink.Windowstyle=1
echo oShellLink.Description="%Desc%"
echo oShellLink.Save)>makelnk.vbs
echo 桌面快捷方式创建成功!
makelnk.vbs
del /f /q makelnk.vbs
exit
goto :eof
:GetWorkDir
set WorkDir=%~dp1
set WorkDir=%WorkDir:~,-1%
goto :eof
使用非常简单,复制保存为BAT文件,将其中的东西改成自己想要的就行了!
找到一个简单的方法
mshta VBScript:Execute("Set a=CreateObject(""WScript.Shell""):Set b=a.CreateShortcut(a.SpecialFolders(""Desktop"") & ""\快捷方式名字.lnk""):b.TargetPath=""程序路径"":b.WorkingDirectory=""%~dp0"":b.Save:close")