Home
Manage Your Code
Snippet: Desktop shortcut and hotkeys (VB.NET)
Title: Desktop shortcut and hotkeys Language: VB.NET
Description: Creating a shortcut programatically Views: 57
Author: Tom Baggett Date Added: 1/26/2012
Copy Code  
1'you must add the reference Com Windows Script Host Object Model
2Imports IWshRuntimeLibrary
3
4Private Sub CreateShortcut()
5        Dim shell As WshShell = New WshShellClass 'Create new instance
6        Dim shortcut As WshShortcut = shell.CreateShortcut("C:\Documents and Settings\tbaggett\Desktop\RunDatasheet.lnk") 'Path of the Shortcut - Where the Shortcut should be placed
7        shortcut.TargetPath = "C:\Program Files\Victory Packaging\Pipeline\RunDatasheet.exe" 'Exe of shortcut
8        shortcut.IconLocation = "C:\Program Files\Victory Packaging\Pipeline\RunDatasheet.exe,0" 'It's icon to use
9        shortcut.Hotkey = "Ctrl+Alt+S"
10        shortcut.Description = "Launches RunDatasheet" 'It's description
11        shortcut.Save() 'Save it.
12    End Sub
Usage
You can't have Imports System.IO in the same class - it interfers with it.