自动为您的应用程序创建快捷方式

本文介绍了一种使用VBScript在Windows环境下自动为应用程序创建桌面及程序文件夹内快捷方式的方法。通过提供的代码示例,读者可以了解到如何利用Windows Script Host对象创建目标路径的快捷方式,并设置工作目录、窗口样式等属性。

在我的安装应用程序中找到:

通过快捷方式访问访问应用程序安装程序

我使用此代码为用户生成快捷方式。 在我的安装程序应用程序中,我将其设置为在用户桌面以及用户“程序”文件夹(单击“开始”->“程序”进入该文件夹)中创建快捷方式。

Public Sub Create_ShortCut(ByVal TargetPath As String, ByVal ShortCutPath As String, ByVal ShortCutname As String, Optional ByVal WorkPath As String, Optional ByVal Window_Style As Integer, Optional ByVal ShortcutLetter As String)
   'Create a Windows Script Host Object
      Dim objWSHShell As Object
      Set objWSHShell = CreateObject("WScript.Shell") 
   'Create shortcut
      Dim MyShortcut As Object
      ShortCutPath = objWSHShell.SpecialFolders(ShortCutPath & "")
      Set MyShortcut = objWSHShell.CreateShortcut(ShortCutPath & "\" & ShortCutname & ".lnk")
      MyShortcut.TargetPath = TargetPath
      MyShortcut.WorkingDirectory = WorkPath
      MyShortcut.WindowStyle = Window_Style
      If strIconFullPath <> "" Then
         MyShortcut.IconLocation = strIconFullPath
      End If
      If ShortcutLetter <> "" And Len(ShortcutLetter) = 1 Then
         MyShortcut.hotkey = "Ctrl+ALT+" & ShortcutLetter
      End If
      MyShortcut.Save 
   'cleanup
      Set MyShortcut = Nothing
      Set objWSHShell = Nothing 
End Sub

From: https://bytes.com/topic/access/insights/933856-create-shortcut-your-application-automatically

评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符  | 博主筛选后可见
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值