Compartilhar via


Clickonce: Shortcut on Desktop is not available

Windows installer or MSI project had inbuilt .lnk shortcut feature available.

We could also use Shell Shortcut

ClickOnce could create shortcut in Startup Menu. However Creating Desktop Shortcut is not available feature in ClickOnce

Please use this program to create desktop shortcut. However this is just copying of Start menu shortcut

So application must be launched first time and second time desktop shortcut could launch it.

Generally ClickOnce launches automatically after installation, if it doesn't please check

Properties | Publish Tab | Option Button | Uncheck "Block application from being activated via a URL"

To create shortcut here is the C# application

-------------------------------------------------------

static void Main(string[] args)

{

Console.WriteLine(Environment.SpecialFolder.Programs);

            try{

            //if(System.Deployment.Application.ApplicationDeployment.CurrentDeployment.IsFirstRun)

                copyShortcut("Companyname", " ApplicationName.appref-ms");

            }

            catch (System.Deployment.Application.InvalidDeploymentException ex)

            {

                Console.WriteLine("Please run this application from the shortcut in the Start Menu to get the automatic update   feature working." +"\n\n" +"You can create a desktop shortcut from that particular shortcut if you like.");

            }

            catch(Exception ex){

                //other exceptions

            }

        }

       static void copyShortcut(string manufacturerName, string shortcutFileName )

       {

        string desktopPath = Environment.GetFolderPath(Environment.SpecialFolder.Desktop) + "\\" + shortcutFileName;

        string startPath = Environment.GetFolderPath(Environment.SpecialFolder.Programs) + "\\" + manufacturerName + "\\" + shortcutFileName;

        try{

            System.IO.File.Copy(startPath, desktopPath, true);

        }

        catch(Exception ex){

            throw ex;

        }

        }

To get the Same code in vb

Please consider this as copy of shortcut and not real shortcut. During uninstall of your product, the desktop shortcut would stay back at desktop