bat命令行创建软件快捷方式,vbs创建软件快捷方式的方法

迅恒数据中心
.VBS直接运行创建快捷方式的代码参考,先在CMD中执行cmd /e:on开启CMD命令扩展:
Set WshShell = WScript.CreateObject("WScript.Shell")
strDesktop = WshShell.SpecialFolders("Desktop") '特殊文件夹“桌面”
set oShellLink = WshShell.CreateShortcut(strDesktop & "\SecureCRT 8.7.3.lnk") '在桌面创建一个快捷方式
oShellLink.TargetPath = "%~dp0\SecureCRT.exe" '目标
oShellLink.WindowStyle = 1 '参数1默认窗口激活,参数3最大化激活,参数7最小化
'oShellLink.Hotkey = "Ctrl+Alt+e" '快捷键,一般不需要设置
'oShellLink.IconLocation = "%~dp0\SecureCRT.exe, 0" '图标,一般不需要设置
oShellLink.Description = "SecureCRT 8.7.3"  '备注
oShellLink.WorkingDirectory = "%~dp0" '起始位置
oShellLink.Save '保存快捷方式参数

.bat中创建快捷方式的代码:
@echo off cmd /e:on  //开启cmd命令扩展,否则下面的%~dp0本目录命令无法获取
(echo Set WshShell=CreateObject("WScript.Shell"^)
echo strDesKtop=WshShell.SpecialFolders("DesKtop"^) '特殊文件夹“桌面”
echo Set oShellLink=WshShell.CreateShortcut(strDesKtop^&"\SecureCRT 8.7.3.lnk"^) '在桌面创建一个快捷方式
echo oShellLink.TargetPath="%~dp0\SecureCRT.exe" '目标
echo oShellLink.WorkingDirectory="%~dp0" '起始位置
echo oShellLink.WindowStyle=1 '1默认窗口,3最大化,7最小化
echo oShellLink.Description = "SecureCRT 8.7.3" '备注
echo oShellLink.Save '保存快捷方式的设置
echo Set oShellLink1=WshShell.CreateShortcut(strDesKtop^&"\SecureFX 8.7.3.lnk"^)
echo oShellLink1.TargetPath="%~dp0\SecureFX.exe"
echo oShellLink1.WorkingDirectory="%~dp0"
echo oShellLink1.WindowStyle=1
echo oShellLink1.Description = "SecureFX 8.7.3"
echo oShellLink1.Save)>makelnk.vbs
makelnk.vbs
del /f /q makelnk.vbs

分类:教程帮助 百度收录 必应收录