Windows Forms Start with Operating System

Asked

Viewed 2,764 times

4

How do I make the user have the option to choose whether the system (system Tray c#) will start with the OS or not through installation in Wizardsetup (Visual Studio 2010)?

  • 1

    What would this Wizardsetup be? Any installation product? Or are you talking about the Setup Wizard present in VS?

  • would be the Wizard setup present in VS

  • You want to know if Wizardsetup has an option that allows you to install and put the application to always start with Windows (in the Startup folder, shell:startup)?

  • type skype, when skype is installed it asks if you want skype to start when booting the operating system.

2 answers

5

Good evening complementing the above answer, There is this method that I use in C# with it you can put to your application start with Windows or even remove it.. how this Voce can put that configuration in the application to start with Windows.. method is this:

public static void SetStartup(bool OnOff)
    {
    try{
    //Nome a ser exibido no registro ou quando Der MSCONFIG - Pode Alterar
        string appName = "SAT Manager - 4Way Systems";

        //Diretorio da chave do Registro NAO ALTERAR
        string runKey = @"SOFTWARE\Microsoft\Windows\CurrentVersion\Run";

        //Abre o registro
        RegistryKey startupKey = Registry.LocalMachine.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", true);

        //Valida se vai incluir o iniciar com o Windows ou remover
        if (OnOff)//Iniciar
        {
            if (startupKey.GetValue(appName) == null)
            {
                // Add startup reg key
                startupKey.SetValue(appName, @""""+ Application.ExecutablePath.ToString()  +@"""");
                startupKey.Close();
            }
        }
        else//Nao iniciar mais
        {
            // remove startup
            startupKey = Registry.LocalMachine.OpenSubKey(runKey, true);
            startupKey.DeleteValue(appName, false);
            startupKey.Close();
        }
        }catch(Exception ex){
        MessageBox.Show(ex.Message);
        }
    }

In some cases the application has to be executed As Administrator to have access to the record.

4


There is the Registry editor where you can register keys. What you need to do is add a boot key to it in the following way: Microsoft Windows Currentversion Run SOFTWARE

But the inclusion of Value should be the way of its application, I’m not sure...

Has a very explanatory link how to use:

setup-and-Deployment-in-visual-studio-2010 Look for the Registry editor part in the link;


You can do it via code too within its application:

Microsoft.Win32.RegistryKey key = Microsoft.Win32.Registry.CurrentUser.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", true);
key.SetValue("Your Application Name", @"Your application path.exe");

There is the Installshield which is not from microsoft but is one of the best there is... . In visual studio Voce has for free the limited version, where it does not support advanced options like the one that Voce is requiring

Link Wizardsetup.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.