Question

I'm creating C++ application and would like to give my users an option to start my application when starting windows. First thing to mind is that I use windows registry to set that, but don't know where to write and what to write. Also, do users need to have admin privileges when running my application so that it is able to write in that part of Windows registry where needed?

Was it helpful?

Solution

You'll need to use the Software\Microsoft\Windows\CurrentVersion\Run key (see the MSDN for additional information). The (string) value should be the path to your application.

You don't need administrative privileges to create it in HKEY_CURRENT_USER, but your application will only start for the current user's session. If you need to start up automatically for all the users, use the HKEY_LOCAL_MACHINE hive with elevated privileges!

OTHER TIPS

The registry is the hidden way to do so; the Startup folder in the Programs menu is the user-visible way to do so. See CSIDL_STARTUP. No admin permissions needed, it's a per-user setting. Admin permissions would be required for CSIDL_COMMON_STARTUP.

You can add the application to start up through registry. I wrote a sample function for you

    public void AddToStartup(string name)
    {
        RegistryKey rkApp = Registry.CurrentUser.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", true);
        rkApp.SetValue(name + ".exe", Application.ExecutablePath.ToString());
    }
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top