1,486
社区成员
发帖
与我相关
我的任务
分享
Public Sub mShellLnk(ByVal LnkName As String, IconFileIconIndex As String, ByVal FilePath As String, Optional ByVal FileName As String, Optional ByVal StrArg As String, Optional ByVal HookKey As String = "", Optional ByVal StrRemark As String = "", Optional ByVal strDesktop As String = "")
Dim WshShell As Object, WScript As Object, oShellLink As Object
Set WshShell = CreateObject("WScript.Shell")
If strDesktop = "" Then strDesktop = WshShell.SpecialFolders("Desktop") '桌面路径
If UCase(Right(LnkName, 4)) = ".LNK" Then
Set oShellLink = WshShell.CreateShortcut(strDesktop & "\" & LnkName) '创建快捷方式,参数为路径和名称
Else
Set oShellLink = WshShell.CreateShortcut(strDesktop & "\" & LnkName & ".lnk")
End If
oShellLink.TargetPath = FilePath & "\" & FileName
oShellLink.Arguments = StrArg
oShellLink.WindowStyle = 1 '风格
oShellLink.Hotkey = HookKey '热键
oShellLink.IconLocation = IconFileIconIndex '图标
oShellLink.Description = StrRemark '快捷方式备注内容
oShellLink.WorkingDirectory = FilePath '源文件所在目录
oShellLink.Save '保存创建的快捷方式
Set WshShell = Nothing
Set oShellLink = Nothing
End Sub