ClickOnce + Windows StartUp Registry

Hi, i have a click-once application that should run as the user logs in the machine.

No problem. The application just adds an entry at the windows registry.

But every time that my clickonce application its updated the registry entry is no longer valid because the application version has already changed.

Any work-arounds

How can I set up my click-once app to starts automatically when the users log-in the machine

tks



Answer this question

ClickOnce + Windows StartUp Registry

  • Skwerl

    Thanks Brian!!

    The whole deal was to refer the "appref-ms" file and not the executable like i was doing.

    Thanks for the reply!!

    Cheers!


  • Tyrael117

    Hi Marcos,

    You can do this with some custom initialization code that runs when your application is first installed:

    public static class ClickOnceHelper

    {

    public static void AddShortcutToStartupGroup(string publisherName, string productName)

    {

    if (ApplicationDeployment.IsNetworkDeployed &&

    ApplicationDeployment.CurrentDeployment.IsFirstRun)

    {

    string startupPath = Environment.GetFolderPath(Environment.SpecialFolder.Startup);

    startupPath = Path.Combine(startupPath, productName) + ".appref-ms";

    if (!File.Exists(startupPath))

    {

    string allProgramsPath = Environment.GetFolderPath(Environment.SpecialFolder.Programs);

    string shortcutPath = Path.Combine(allProgramsPath, publisherName);

    shortcutPath = Path.Combine(shortcutPath, productName) + ".appref-ms";

    File.Copy(shortcutPath, startupPath);

    }

    }

    }

    }

    Hope that helps,

    Brian Noyes

    Author of Smart Client Deployment with ClickOnce, Data Binding with Windows Forms 2.0



  • scott bates

    public static class ClickOnceHelper

    {

    public static void AddShortcutToStartupGroup(string publisherName, string productName)

    {

    if (ApplicationDeployment.IsNetworkDeployed &&

    ApplicationDeployment.CurrentDeployment.IsFirstRun)

    {

    string startupPath = Environment.GetFolderPath(Environment.SpecialFolder.Startup);

    startupPath = Path.Combine(startupPath, productName) + ".appref-ms";

    if (!File.Exists(startupPath))

    {

    string allProgramsPath = Environment.GetFolderPath(Environment.SpecialFolder.Programs);

    string shortcutPath = Path.Combine(allProgramsPath, publisherName);

    shortcutPath = Path.Combine(shortcutPath, productName) + ".appref-ms";

    File.Copy(shortcutPath, startupPath);

    }

    }

    }

    }

    CurrentDeployment is null, if it isnt network deployed. FYI.

    This will throw an exception during debug, or other times not network deployed.



  • ClickOnce + Windows StartUp Registry