Следующий код создаст ярлык для запущенного приложения в меню «Пуск» (для этого вам потребуются необходимые разрешения):
Во-первых, Добавить ссылку -> вкладка COM -> Хост-объект Windows ScriptМодель
Imports IWshRuntimeLibrary
Public Function CreateShortcut(ByVal fileName As String, ByVal description As String) As Boolean
Try
Dim shell As New WshShell
'the following is the root of the Start Menu so if you want it in a folder you need to create it
Dim ShortcutDir As String = Environment.GetFolderPath(Environment.SpecialFolder.CommonStartMenu)
Dim shortCut As IWshRuntimeLibrary.IWshShortcut
' short cut files have a .lnk extension
shortCut = CType(shell.CreateShortcut(ShortcutDir & "\" & fileName & ".lnk"), IWshRuntimeLibrary.IWshShortcut)
' set the shortcut properties
With shortCut
.TargetPath = System.Reflection.Assembly.GetExecutingAssembly.Location()
.WindowStyle = 1
.Description = description
.WorkingDirectory = ShortcutDir
' the next line gets the first Icon from the executing program
.IconLocation = System.Reflection.Assembly.GetExecutingAssembly.Location() & ", 0"
'.Arguments = ""
.Save()
End With
Return True
Catch ex As System.Exception
' add your error handling here
Return False
End Try
End Function