一区二区三区在线-一区二区三区亚洲视频-一区二区三区亚洲-一区二区三区午夜-一区二区三区四区在线视频-一区二区三区四区在线免费观看

腳本之家,腳本語言編程技術(shù)及教程分享平臺!
分類導(dǎo)航

Python|VBS|Ruby|Lua|perl|VBA|Golang|PowerShell|Erlang|autoit|Dos|bat|

服務(wù)器之家 - 腳本之家 - VBS - 使用VBS創(chuàng)建快捷方式的代碼

使用VBS創(chuàng)建快捷方式的代碼

2021-11-13 10:59墨言 VBS

昨天為大家分享了使用bat結(jié)合vbs實(shí)現(xiàn)創(chuàng)建快捷方式,今天接著用純vbs為大家分享一下

在網(wǎng)吧維護(hù)過程中經(jīng)常要發(fā)送桌面快捷方式,有什么批處理的方式能便捷發(fā)送桌面快捷方式呢,就拿我這邊網(wǎng)吧steam下發(fā)為例給大家一個參考,如果要使用直接復(fù)制下面代碼改下具體參數(shù)就行了。代碼如下:

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
@echo off
::設(shè)置程序或文件的路徑(必選)
set Program=D:\Program Files\Microvirt\MEmu\MEmu.exe
 
::設(shè)置啟動參數(shù)(可選)
set  Arguments=
 
::設(shè)置快捷方式名稱(必選)
set LnkName=test
 
::設(shè)置程序的工作路徑,一般為程序主目錄,此項若留空,腳本將自行分析路徑
set WorkDir=
 
::設(shè)置快捷方式顯示的說明(可選)
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 桌面快捷方式創(chuàng)建成功!
makelnk.vbs
del /f /q makelnk.vbs
exit
goto :eof
:GetWorkDir
set WorkDir=%~dp1
set WorkDir=%WorkDir:~,-1%
goto :eof

VBS:

第1個是桌面上創(chuàng)建快捷方式的應(yīng)用范例

?
1
2
3
4
5
6
7
8
9
10
Set WshShell = WScript.CreateObject("WScript.Shell")
strDesktop = WshShell.SpecialFolders("Desktop") :'特殊文件夾“桌面”
set oShellLink = WshShell.CreateShortcut(strDesktop & "\計算器.lnk")
oShellLink.TargetPath = "C:\Windows\System32\Calc.exe" : '目標(biāo)
oShellLink.WindowStyle = 3 :'參數(shù)1默認(rèn)窗口激活,參數(shù)3最大化激活,參數(shù)7最小化
oShellLink.Hotkey = "Ctrl+Alt+C" : '快捷鍵
oShellLink.IconLocation = "C:\Windows\System32\Calc.exe" : '圖標(biāo)
oShellLink.Description = "系統(tǒng)默認(rèn)計算器" : '備注
oShellLink.WorkingDirectory = strDesktop : '起始位置
oShellLink.Save : '創(chuàng)建保存快捷方式

第2個是自定義目錄位置上創(chuàng)建快捷方式的應(yīng)用范例

?
1
2
3
4
5
6
7
8
9
Set WshShell = WScript.CreateObject("WScript.Shell")
set oShellLink = WshShell.CreateShortcut("C:\Documents and Settings\Administrator\計算器調(diào)試.lnk")
oShellLink.IconLocation = "C:\Documents and Settings\Administrator\Calc.exe" : '圖標(biāo)
oShellLink.TargetPath = "C:\Documents and Settings\Administrator\Calc.exe" : '目標(biāo)
oShellLink.WorkingDirectory = "C:\Documents and Settings\Administrator\" : '起始位置
oShellLink.Hotkey = "Ctrl+Alt+C" : '快捷鍵
oShellLink.WindowStyle = 3 :'運(yùn)行方式,參數(shù)1默認(rèn)窗口激活,參數(shù)3最大化激活,參數(shù)7最小化
oShellLink.Description = "系統(tǒng)默認(rèn)計算器" : '備注
oShellLink.Save : '創(chuàng)建保存快捷方式

以下內(nèi)容另存為 XXX.js

也是bat中經(jīng)常調(diào)用的vbs

?
1
2
3
4
5
6
7
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();

可以增加可判斷系統(tǒng)板本的:

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
Set WshShell = WScript.CreateObject("WScript.Shell")
strDesktop = WshShell.SpecialFolders("Desktop")
set oShellLink = WshShell.CreateShortcut(strDesktop & "\xxx系統(tǒng).lnk")
 
Dim fso
Set fso=CreateObject("Scripting.FileSystemObject")       
If fso.folderExists("C:\\Program Files (x86)") Then '通過目錄來判斷是32位還是64位操作系統(tǒng)       
    oShellLink.TargetPath = "C:\Program Files (x86)\Google\Chrome\Application\chrome.exe" '目標(biāo)
    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/" '運(yùn)行參數(shù)
oShellLink.WindowStyle = 1 '參數(shù)1默認(rèn)窗口激活,參數(shù)3最大化激活,參數(shù)7最小化
oShellLink.Hotkey = "" '快捷鍵
oShellLink.IconLocation = "C:\Program Files\ChromeStandaloneSetup\favicon.ico" '圖標(biāo)
oShellLink.Description = ""
oShellLink.Save '創(chuàng)建保存快捷方式

支持帶參數(shù)的

?
1
2
3
4
5
6
7
8
9
10
11
set WshShell = WScript.CreateObject("WScript.Shell")
strDesktop = WshShell.SpecialFolders("Desktop") '獲取桌面路徑
set oShellLink = WshShell.CreateShortcut(strDesktop & "\騰訊QQ.lnk")   '快捷方式將要保存到的完全路徑
oShellLink.TargetPath = "http://www.hao123.com/" '快捷方式里的“目標(biāo)”
oShellLink.Arguments = "/參數(shù)1 /參數(shù)2"    '“目標(biāo)”的運(yùn)行參數(shù),無參數(shù)時,直接=""
oShellLink.WindowStyle = 1   '快捷方式里的“運(yùn)行方式”
oShellLink.Hotkey = "Ctrl+Alt+e"   '快捷方式里的“快捷鍵”
oShellLink.IconLocation = "C:\Program Files\Tencent\qq.exe, 0"   '快捷方式的圖標(biāo)
oShellLink.Description = "騰訊QQ"   '快捷方式里的“備注”
oShellLink.WorkingDirectory = "C:\Program Files\Tencent"   '快捷方式里的“起始位置”
oShellLink.Save '使用以上的設(shè)置創(chuàng)建快捷方式

下面是其他網(wǎng)友的補(bǔ)充

利用VBS創(chuàng)建快捷方式詳細(xì)說明

以下內(nèi)容另存為 XXX.VBS

第1個是桌面上創(chuàng)建快捷方式的應(yīng)用范例

?
1
2
3
4
5
6
7
8
9
10
Set WshShell = WScript.CreateObject("WScript.Shell")
strDesktop = WshShell.SpecialFolders("Desktop") :'特殊文件夾“桌面”
set oShellLink = WshShell.CreateShortcut(strDesktop & "\計算器.lnk")
oShellLink.TargetPath = "C:\Windows\System32\Calc.exe" : '目標(biāo)
oShellLink.WindowStyle = 3 :'參數(shù)1默認(rèn)窗口激活,參數(shù)3最大化激活,參數(shù)7最小化
oShellLink.Hotkey = "Ctrl+Alt+C" : '快捷鍵
oShellLink.IconLocation = "C:\Windows\System32\Calc.exe" : '圖標(biāo)
oShellLink.Description = "系統(tǒng)默認(rèn)計算器" : '備注
oShellLink.WorkingDirectory = strDesktop : '起始位置
oShellLink.Save : '創(chuàng)建保存快捷方式

第2個是自定義目錄位置上創(chuàng)建快捷方式的應(yīng)用范例

?
1
2
3
4
5
6
7
8
9
Set WshShell = WScript.CreateObject("WScript.Shell")
set oShellLink = WshShell.CreateShortcut("C:\Documents and Settings\Administrator\計算器調(diào)試.lnk")
oShellLink.IconLocation = "C:\Documents and Settings\Administrator\Calc.exe" : '圖標(biāo)
oShellLink.TargetPath = "C:\Documents and Settings\Administrator\Calc.exe" : '目標(biāo)
oShellLink.WorkingDirectory = "C:\Documents and Settings\Administrator\" : '起始位置
oShellLink.Hotkey = "Ctrl+Alt+C" : '快捷鍵
oShellLink.WindowStyle = 3 :'運(yùn)行方式,參數(shù)1默認(rèn)窗口激活,參數(shù)3最大化激活,參數(shù)7最小化
oShellLink.Description = "系統(tǒng)默認(rèn)計算器" : '備注
oShellLink.Save : '創(chuàng)建保存快捷方式

以下內(nèi)容另存為 XXX.js

第3個是自定義目錄位置上以JS類創(chuàng)建快捷方式的應(yīng)用范例

?
1
2
3
4
5
6
7
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腳本對比我們可以發(fā)現(xiàn)有共同點(diǎn)之處,此類腳本開始都要聲明以下內(nèi)容以什么程序來解析運(yùn)行,聲明好了,接下去才是具體的步驟.

看如何在bat中調(diào)用vbs

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
@echo off
title 服務(wù)器之家 桌面快捷方式創(chuàng)建工具!
 
>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")

到此這篇關(guān)于使用VBS創(chuàng)建快捷方式的代碼的文章就介紹到這了,更多相關(guān)VBS創(chuàng)建快捷方式內(nèi)容請搜索服務(wù)器之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持服務(wù)器之家!

原文鏈接:https://www.moyann.com/archives/150/

延伸 · 閱讀

精彩推薦
主站蜘蛛池模板: 日本十大顶级绝伦推理片 | 久草在在线免视频在线观看 | 国产不卡视频一区二区在线观看 | 国产精品国色综合久久 | 国产主播福利在线观看 | 香蕉国产人午夜视频在线观看 | 日本一卡=卡三卡免费 | 欧美不卡一区二区三区 | 天美传媒果冻传媒星空传媒 | 久久久无码精品亚洲A片猫咪 | h版在线观看 | 午夜伦伦电影理论片大片 | 青青草原国产 | 日本无吗免费一二区 | 激情三级hd中文字幕 | 999精品视频在线观看热6 | 亚洲美女爱爱 | 放荡的女老板bd中文字幕 | 天天碰夜夜操 | 洗濯屋し在线观看 | 草莓香蕉绿巨人丝瓜榴莲污在线观看 | 性色生活片在线观看 | 成年人免费在线播放 | 久久精品国产只有精品 | 精品国产一区二区三区在线 | 亚洲国产免费 | 好紧好爽的午夜寂寞视频 | 青青草原国产在线 | 国产情侣露脸自拍 | 天堂中文在线免费观看 | 四虎影免看黄 | 青青操在线 | 骚虎网站在线观看 | 日本在线看免费 | 亚洲人成网站在线观看90影院 | 情趣内衣在线观看 | 日本无遮挡拍拍拍凤凰 | 国产精品成| 6080午夜| 亚洲香蕉网久久综合影院3p | 美女国内精品自产拍在线播放 |