REM 以管理员权限运行
Set WshShell = WScript.CreateObject("WScript.Shell")
If WScript.Arguments.Length = 0 Then
Set ObjShell = CreateObject("Shell.Application")
ObjShell.ShellExecute "wscript.exe" _
, """" & WScript.ScriptFullName & """ RunAsAdministrator", , "runas", 1
WScript.Quit
End if
REM 调用Browse选择文件夹
Const WINDOW_HANDLE = 0
Const NO_OPTIONS = 0
Set objShell = CreateObject("Shell.Application")
Set objFolder = objShell.BrowseForFolder _
(WINDOW_HANDLE, "Select a folder:", NO_OPTIONS)
If objFolder Is Nothing Then
MsgBox "选择不能为空??"
WScript.Quit
End if
If objFolder & "" = "" Then '如果为空或NULL
MsgBox "选择不能为空"
WScript.Quit
End if
dirPath = objFolder.Self.Path
REM 开始调用输入框
dim str
str = InputBox("请输入快捷方式名称")
If str & ""="" Then '如果为空或NULL
MsgBox "名称不能为空"
WScript.Quit
End if
REM 创建文件夹快捷方式
set oShellLink = WshShell.CreateShortcut("C:\ProgramData\Microsoft\Windows\Start Menu\Programs\快捷文件夹\" & str & ".lnk")
REM oShellLink.IconLocation = "" : '图标
oShellLink.TargetPath = dirPath : '目标
REM oShellLink.WorkingDirectory = "" : '起始位置
REM oShellLink.Hotkey = "" : '快捷键
oShellLink.WindowStyle = 1 :'运行方式,参数1默认窗口激活,参数3最大化激活,参数7最小化
REM oShellLink.Description = "系统默认计算器" : '备注
oShellLink.Save : '创建保存快捷方式
标签:oShellLink,开始菜单,WScript,VBS,文件夹,为空,REM,快捷方式
From: https://www.cnblogs.com/qs-smile/p/17038721.html