How to create a windows shortcut?

Or use OLE to access the scripting host directly:

Public Function CreateShortcut(Target As FolderItem, Name As String) As FolderItem
  #If TargetWin32 Then
    Dim shortcut As FolderItem = SpecialFolder.Temporary.Child(Name + ".lnk") 
    Dim WSHScript As New OLEObject("{F935DC22-1CF0-11D0-ADB9-00C04FD58A0B}")
    Dim WSHShortcut As OLEObject = WSHScript.CreateShortcut(shortcut.NativePath)
    If WSHShortcut <> Nil Then
      WSHShortcut.Description = Name
      WSHShortcut.TargetPath = Target.NativePath
      WSHShortcut.WorkingDirectory = Target.NativePath
      WSHShortcut.Save()
      Return shortcut
    End If
  #endif
End Function
2 Likes