在网吧维护过程中经常要发送桌面快捷方式,有什么批处理的方式能便捷发送桌面快捷方式呢,就拿我这边网吧steam下发为例给大家一个参考,如果要使用直接复制下面代码改下具体参数就行了。代码如下:

@echo off
::设置程序或文件的路径(必选)
set program=d:\program files\microvirt\memu\memu.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:

第1个是桌面上创建快捷方式的应用范例

set wshshell = wscript.createobject("wscript.shell")
strdesktop = wshshell.specialfolders("desktop") :'特殊文件夹“桌面”
set oshelllink = wshshell.createshortcut(strdesktop & "\计算器.lnk")
oshelllink.targetpath = "c:\windows\system32\calc.exe" : '目标
oshelllink.windowstyle = 3 :'参数1默认窗口激活,参数3最大化激活,参数7最小化
oshelllink.hotkey = "ctrl+alt+c" : '快捷键
oshelllink.iconlocation = "c:\windows\system32\calc.exe" : '图标
oshelllink.description = "系统默认计算器" : '备注
oshelllink.workingdirectory = strdesktop : '起始位置
oshelllink.save : '创建保存快捷方式

第2个是自定义目录位置上创建快捷方式的应用范例

set wshshell = wscript.createobject("wscript.shell")
set oshelllink = wshshell.createshortcut("c:\documents and settings\administrator\计算器调试.lnk")
oshelllink.iconlocation = "c:\documents and settings\administrator\calc.exe" : '图标
oshelllink.targetpath = "c:\documents and settings\administrator\calc.exe" : '目标
oshelllink.workingdirectory = "c:\documents and settings\administrator\" : '起始位置
oshelllink.hotkey = "ctrl+alt+c" : '快捷键
oshelllink.windowstyle = 3 :'运行方式,参数1默认窗口激活,参数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 settings\administrator\favorites\\游戏菜单.lnk");
ourl.targetpath = "e:\\nbmsclient\\barclientview.exe";
ourl.iconlocation = "e:\\nbmsclient\\barclientview.exe";
ourl.workingdirectory = "e:\\nbmsclient";
ourl.save();

可以增加可判断系统板本的:

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位还是64位操作系统        
    oshelllink.targetpath = "c:\program files (x86)\google\chrome\application\chrome.exe" '目标
    oshelllink.workingdirectory = "c:\program files (x86)\google\chrome\application\" '起始位置
else 
    oshelllink.targetpath = "c:\program files\google\chrome\application\chrome.exe" 
    oshelllink.workingdirectory = "c:\program files\google\chrome\application\"     
end if
oshelllink.arguments = "http://192.168.0.1:8080/xxx/" '运行参数
oshelllink.windowstyle = 1 '参数1默认窗口激活,参数3最大化激活,参数7最小化
oshelllink.hotkey = "" '快捷键
oshelllink.iconlocation = "c:\program files\chromestandalonesetup\favicon.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 files\tencent\qq.exe, 0"   '快捷方式的图标
oshelllink.description = "腾讯qq"   '快捷方式里的“备注”
oshelllink.workingdirectory = "c:\program files\tencent"   '快捷方式里的“起始位置”
oshelllink.save '使用以上的设置创建快捷方式

下面是其他网友的补充

利用vbs创建快捷方式详细说明

以下内容另存为 xxx.vbs

第1个是桌面上创建快捷方式的应用范例

set wshshell = wscript.createobject("wscript.shell")
strdesktop = wshshell.specialfolders("desktop") :'特殊文件夹“桌面”
set oshelllink = wshshell.createshortcut(strdesktop & "\计算器.lnk")
oshelllink.targetpath = "c:\windows\system32\calc.exe" : '目标
oshelllink.windowstyle = 3 :'参数1默认窗口激活,参数3最大化激活,参数7最小化
oshelllink.hotkey = "ctrl+alt+c" : '快捷键
oshelllink.iconlocation = "c:\windows\system32\calc.exe" : '图标
oshelllink.description = "系统默认计算器" : '备注
oshelllink.workingdirectory = strdesktop : '起始位置
oshelllink.save : '创建保存快捷方式

第2个是自定义目录位置上创建快捷方式的应用范例

set wshshell = wscript.createobject("wscript.shell")
set oshelllink = wshshell.createshortcut("c:\documents and settings\administrator\计算器调试.lnk")
oshelllink.iconlocation = "c:\documents and settings\administrator\calc.exe" : '图标
oshelllink.targetpath = "c:\documents and settings\administrator\calc.exe" : '目标
oshelllink.workingdirectory = "c:\documents and settings\administrator\" : '起始位置
oshelllink.hotkey = "ctrl+alt+c" : '快捷键
oshelllink.windowstyle = 3 :'运行方式,参数1默认窗口激活,参数3最大化激活,参数7最小化
oshelllink.description = "系统默认计算器" : '备注
oshelllink.save : '创建保存快捷方式

以下内容另存为 xxx.js

第3个是自定义目录位置上以js类创建快捷方式的应用范例

var fso = new activexobject("scripting.filesystemobject");
var shl = wscript.createobject("wscript.shell");
var ourl = shl.createshortcut("c:\documents and settings\administrator\favorites\\游戏菜单.lnk");
ourl.targetpath = "e:\\nbmsclient\\barclientview.exe";
ourl.iconlocation = "e:\\nbmsclient\\barclientview.exe";
ourl.workingdirectory = "e:\\nbmsclient";
ourl.save();

从以上vbs和js脚本对比我们可以发现有共同点之处,此类脚本开始都要声明以下内容以什么程序来解析运行,声明好了,接下去才是具体的步骤.

看如何在bat中调用vbs

@echo off
title www.887551.com 桌面快捷方式创建工具!

>nul 2>&1 reg.exe query "hku\s-1-5-19" || (
    echo set uac = createobject^("shell.application"^) > "%temp%\getadmin.vbs"
    echo uac.shellexecute "%~f0", "%1", "", "runas", 1 >> "%temp%\getadmin.vbs"
    "%temp%\getadmin.vbs"
    del /f /q "%temp%\getadmin.vbs" 2>nul
    exit /b
)
set jb51name=ditto3.lnk
set jb51path=%~dp0
set jb51exec=%~dp0ditto.exe

mshta vbscript:execute("set a=createobject(""wscript.shell""):set b=a.createshortcut(a.specialfolders(""desktop"") & ""\%jb51name%""):b.targetpath=""%jb51exec%"":b.workingdirectory=""%jb51path%"":b.save:close")

到此这篇关于使用vbs创建快捷方式的代码的文章就介绍到这了,更多相关vbs创建快捷方式内容请搜索www.887551.com以前的文章或继续浏览下面的相关文章希望大家以后多多支持www.887551.com!