首页脚本使用VBS创建快捷方式的代码

使用VBS创建快捷方式的代码

时间2024-02-11 19:03:03发布访客分类脚本浏览258
导读:收集整理的这篇文章主要介绍了使用VBS创建快捷方式的代码,觉得挺不错的,现在分享给大家,也给大家做个参考。 在网吧维护过程中经常要发送桌面快捷方式,有什么批处理的方式能便捷发送桌面快捷方...
收集整理的这篇文章主要介绍了使用VBS创建快捷方式的代码,觉得挺不错的,现在分享给大家,也给大家做个参考。

在网吧维护过程中经常要发送桌面快捷方式,有什么批处理的方式能便捷发送桌面快捷方式呢,就拿我这边网吧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=1echo oShellLink.Description="%Desc%"echo oShellLink.Save)>
    makelnk.vbsecho 桌面快捷方式创建成功!makelnk.vbsdel /f /q makelnk.vbsexITgoto :eof:GetWorkDirset WorkDir=%~dp1set 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 fsoSet 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 IfoShellLink.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 offtitle  桌面快捷方式创建工具!>
    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.lnkset jb51path=%~dp0set jb51exec=%~dp0Ditto.exemshta 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创建快捷方式内容请搜索以前的文章或继续浏览下面的相关文章希望大家以后多多支持!

您可能感兴趣的文章:
  • 通过vbs修改目录名称与快捷方式名称的实现代码
  • 右键发送(sendto),创建快捷方式到自定义的位置 的vbs
  • 批量替换快捷方式目的路径的VBS脚本
  • 批处理BAT创建快捷方式
  • bat脚本实例实现只允许运行一个实例(安装程序、创建快捷方式脚本)
  • 用bat实现打开快捷方式指向的目录
  • 批处理cmd之桌面快捷方式创建工具

声明:本文内容由网友自发贡献,本站不承担相应法律责任。对本内容有异议或投诉,请联系2913721942#qq.com核实处理,我们将尽快回复您,谢谢合作!


若转载请注明出处: 使用VBS创建快捷方式的代码
本文地址: https://pptw.com/jishu/610194.html
如何用VBS脚本收集远程计算机或本地计算机安装的软件 access怎么更新查询替换数据

游客 回复需填写必要信息