A common approach for programmatically creating a shortcut to a ClickOnce application is to copy the “Application Reference” (*.appref-ms) file that was created in the user’s start menu when the application was installed.
The following function will create a ClickOnce Application Shortcut (*.appref-ms) file for the currently running ClickOnce application without coping the file that exists in the user’s start menu:
''' Creates a ClickOnce application reference (*.appref-ms) file for the
''' currently running ClickOnce application.
''' <param name="location">
''' Path, including file name, of the new ClickOnce application reference
''' file to create. File should have an ".appref-ms" extension.
Public Sub CreateClickOnceShortcut( _
ByVal location As String)
Dim updateLocation As Uri = _
Dim AppSecurityInfo As New Security.Policy.ApplicationSecurityInfo( _
Dim DeploymentInfo As ApplicationId = AppSecurityInfo.DeploymentId
Dim PublicKey As Byte() = DeploymentInfo.PublicKeyToken
Using ShortcutFile As New IO.StreamWriter( _
location, False, System.Text.Encoding.Unicode)
ShortcutFile.Write(updateLocation.ToString().Replace(" ", "%20"))
ShortcutFile.Write(", Culture=neutral, PublicKeyToken=")
For i As Integer = 0 To (PublicKey.Length - 1)
It appears that the ClickOnce application’s manifest must be signed for the shortcut’s application specific icon to appear. If it is not signed, the default application icon appears.