使用VBS创建快捷方式的代? target= |
ıǩVBS创建快捷方式 在网吧维护过程中经常要发送桌面快捷方式,有什么批处理的方式能便捷发送桌面快捷方式呢,就拿我这边网吧steam下发为例给大家一个参考,如果要使用直接复制下面代码改下具体参数就行了。代码如下: @echo off ::设置程序或文件的路径(必选) set Program=D:Program FilesMicrovirtMEmuMEmu.exe ::设置启动参数(可选) set Arguments= ::设置快捷方式名称(必选) set LnkName=test ::设置程序的工作路径,一般为程序主目录,此项若留空,脚本将自行分析路? set WorkDir= ::设置快捷方式显示的说明(可选) set Desc= 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.Arguments="%Arguments%" 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 VBS: ?个是桌面上创建快捷方式的应用范例 Set WshShell = WScript.CreateObject("WScript.Shell") strDesktop = WshShell.SpecialFolders("Desktop") :'特殊文件夹“桌面? set oShellLink = WshShell.CreateShortcut(strDesktop & "计算?lnk") oShellLink.TargetPath = "C:WindowsSystem32Calc.exe" : '目标 oShellLink.WindowStyle = 3 :'参数1默认窗口激活,参数3最大化激活,参数7最小化 oShellLink.Hotkey = "Ctrl+Alt+C" : '快捷? oShellLink.IconLocation = "C:WindowsSystem32Calc.exe" : '图标 oShellLink.Description = "系统默认计算? : '备注 oShellLink.WorkingDirectory = strDesktop : '起始位置 oShellLink.Save : '创建保存快捷方式 ?个是自定义目录位置上创建快捷方式的应用范?/p> Set WshShell = WScript.CreateObject("WScript.Shell") set oShellLink = WshShell.CreateShortcut("C:Documents and SettingsAdministrator计算器调?lnk") oShellLink.IconLocation = "C:Documents and SettingsAdministratorCalc.exe" : '图标 oShellLink.TargetPath = "C:Documents and SettingsAdministratorCalc.exe" : '目标 oShellLink.WorkingDirectory = "C:Documents and SettingsAdministrator" : '起始位置 oShellLink.Hotkey = "Ctrl+Alt+C" : '快捷? oShellLink.WindowStyle = 3 :'运行方式,参?默认窗口激活,参数3最大化激活,参数7最小化 oShellLink.Description = "系统默认计算? : '备注 oShellLink.Save : '创建保存快捷方式 以下内容另存?XXX.js 也是bat中经常调用的vbs var fso = new ActiveXObject("Scripting.FileSystemObject"); var shl = WScript.CreateObject("WScript.Shell"); var oUrl = shl.CreateShortcut("C:Documents and SettingsAdministratorFavorites\游戏菜单.lnk"); oUrl.TargetPath = "E:\nbmsclient\BarClientView.exe"; oUrl.IconLocation = "E:\nbmsclient\BarClientView.exe"; oUrl.WorkingDirectory = "E:\nbmsclient"; oUrl.Save(); 可以增加可判断系统板本的?/p> Set WshShell = WScript.CreateObject("WScript.Shell") strDesktop = WshShell.SpecialFolders("Desktop") set oShellLink = WshShell.CreateShortcut(strDesktop & "xxx系统.lnk") Dim fso Set fso=CreateObject("Scripting.FileSystemObject") If fso.folderExists("C:\Program Files (x86)") Then '通过目录来判断是32位还?4位操作系? oShellLink.TargetPath = "C:Program Files (x86)GoogleChromeApplicationchrome.exe" '目标 oShellLink.WorkingDirectory = "C:Program Files (x86)GoogleChromeApplication" '起始位置 Else oShellLink.TargetPath = "C:Program FilesGoogleChromeApplicationchrome.exe" oShellLink.WorkingDirectory = "C:Program FilesGoogleChromeApplication" End If oShellLink.Arguments = "http://192.168.0.1:8080/xxx/" '运行参数 oShellLink.WindowStyle = 1 '参数1默认窗口激活,参数3最大化激活,参数7最小化 oShellLink.Hotkey = "" '快捷? oShellLink.IconLocation = "C:Program FilesChromeStandaloneSetupfavicon.ico" '图标 oShellLink.Description = "" oShellLink.Save '创建保存快捷方式 支持带参数的 set WshShell = WScript.CreateObject("WScript.Shell") strDesktop = WshShell.SpecialFolders("Desktop") '获取桌面路径 set oShellLink = WshShell.CreateShortcut(strDesktop & "腾讯QQ.lnk") '快捷方式将要保存到的完全路径 oShellLink.TargetPath = "http://www.hao123.com/" '快捷方式里的“目标? oShellLink.Arguments = "/参数1 /参数2" '“目标”的运行参数,无参数时,直?"" oShellLink.WindowStyle = 1 '快捷方式里的“运行方式? oShellLink.Hotkey = "Ctrl+Alt+e" '快捷方式里的“快捷键? oShellLink.IconLocation = "C:Program FilesTencentqq.exe, 0" '快捷方式的图? oShellLink.Description = "腾讯QQ" '快捷方式里的“备注? oShellLink.WorkingDirectory = "C:Program FilesTencent" '快捷方式里的“起始位置? oShellLink.Save '使用以上的设置创建快捷方?/pre> 下面是其他网友的补充 利用VBS创建快捷方式详细说明
|