代码之家  ›  专栏  ›  技术社区  ›  Matt

在Windows 7 box(64位)上从vb.net创建快捷方式

  •  2
  • Matt  · 技术社区  · 15 年前

    Imports IWshRuntimeLibrary
    
    Dim WshShell As WshShellClass = New WshShellClass
    
                Dim MyShortcut As IWshRuntimeLibrary.IWshShortcut
    
                ' The shortcut will be created on the desktop
                'Win 7 
                MyShortcut = CType(WshShell.CreateShortcut("C:\Users\Public\Desktop\iexplore.lnk"), IWshRuntimeLibrary.IWshShortcut)
    
                'MyShortcut = CType(WshShell.CreateShortcut("C:\Documents and Settings\All Users\Desktop\iexplore.lnk"), IWshRuntimeLibrary.IWshShortcut)
    
                MyShortcut.TargetPath = "C:\Program Files\Internet Explorer\iexplore.exe" 'Specify target app full path
                MyShortcut.Description = "IE"
    
                MyShortcut.Save()
    

    2 回复  |  直到 15 年前
        1
  •  2
  •   David Crowell    15 年前

    Windows 7 64位。将其编译为32位,并成功:

    Imports IWshRuntimeLibrary
    
    Module Module1
    
        Sub Main()
            Dim WshShell As WshShell = New WshShell
    
            Dim MyShortcut As IWshRuntimeLibrary.IWshShortcut
    
            MyShortcut = CType(WshShell.CreateShortcut("C:\Users\Public\Desktop\Dah Browser.lnk"), IWshRuntimeLibrary.IWshShortcut)
            MyShortcut.TargetPath = "C:\Program Files\Internet Explorer\iexplore.exe" 'Specify target app full path
            MyShortcut.Description = "IE"
    
            MyShortcut.Save()
        End Sub
    
    End Module
    

    注意:我以管理员身份运行,UAC已关闭。

    还要注意,我将WshShellClass更改为WshShell

        2
  •  0
  •   Walter    15 年前

    你的应用程序在什么特权下运行?我相信它将需要管理员凭据做什么,你正在寻找。