Search code examples
c#windowsstartup

How to make an exe start at the Windows Startup


Possible Duplicate:
How to put exe file in windows Startup

Suppose I have built an application in C#, Once I install it, I want it to run in the background whenever windows starts up,or you can say a user logs in to his windows account. Is there any way I can do that? Except writing a windows service?

The application basically shows messages when a certain event is triggered Thanks


Solution

  • Add to shortcut to Windows start-up folder:

    Environment.GetFolderPath(Environment.SpecialFolder.Startup)
    

    Or add to registry, something like this:

    RegistryKey add = Registry.CurrentUser.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", true);
    add.SetValue("Your App Name", "\"" + Application.ExecutablePath.ToString() + "\"");
    

    You can change CurrentUser to LocalMachine if you want it to run with every user. Thanks to Aidiakapi.