想自动创建QQ的快捷启动,需要带参数,网上提供了一种
Option Explicit
Public Sub mShellLnk(ByVal LnkName As String, IconFileIconIndex As String, ByVal FilePath As String, Optional ByVal FileName As String, Optional ByVal HookKey As String = "", Optional ByVal StrRe 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.WindowStyle = 1 '风格
oShellLink.Hotkey = HookKey '热键
oShellLink.IconLocation = IconFileIconIndex '图标
oShellLink.Description = StrRe '快捷方式备注内容
oShellLink.WorkingDirectory = FilePath '源文件所在目录
oShellLink.Save '保存创建的快捷方式
Set WshShell = Nothing
Set oShellLink = Nothing
End Sub
的方法,可是这个方法,我做不到带参数。谁有别的方法做一个带参数快捷方式的方法呢?
只要成功,就全给分
Option Explicit
Public Sub mShellLnk(ByVal LnkName As String, IconFileIconIndex As String, ByVal FilePath As String, Optional ByVal FileName As String, Optional ByVal HookKey As String = "", Optional ByVal StrRe 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.WindowStyle = 1 '风格
oShellLink.Hotkey = HookKey '热键
oShellLink.IconLocation = IconFileIconIndex '图标
oShellLink.Description = StrRe '快捷方式备注内容
oShellLink.WorkingDirectory = FilePath '源文件所在目录
oShellLink.Save '保存创建的快捷方式
Set WshShell = Nothing
Set oShellLink = Nothing
End Sub
的方法,可是这个方法,我做不到带参数。谁有别的方法做一个带参数快捷方式的方法呢?
只要成功,就全给分
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 = StrRe '快捷方式备注内容
oShellLink.WorkingDirectory = FilePath '源文件所在目录
oShellLink.Save '保存创建的快捷方式
Set WshShell = Nothing
Set oShellLink = Nothing
End Sub例子:mShellLnk "TestLnk","notepad.exe","C:\windows\", "notepad.exe", "test.txt"PS:其实LZ自己看一下,也会发现啊,也就那么几个成员....
怎么解决啊?
Set objShell = CreateObject("Wscript.Shell")
Set objShellLink = objShell.CreateShortcut("测试快捷方式.lnk")
objShellLink.TargetPath = cmd
objShellLink.Arguments = "备注内容"
objShellLink.Save把以上代码写进记事本,保存名为*.vbs运行,就可看到效果了,再一次谢谢老马