I am creating a program in c++, which I want to be able to have the option to have users let it auto start in windows. So when a user starts his computer, windows will auto start this program. I have read stuff about modifying the registry or putting it in the startup folder, but what would be the best "clean" way to do this?
Startup folder is clean enough.
Gives the user the possibility to remove it if needed.
Refer this link http://ask-leo.com/auto_start_how_do_i_run_a_program_automatically_when_windows_starts.html
Depending on whether you're executing an all-user or per-user install, put it in the Startup folder for All Users or the per-user Startup folder. The Startup folder you see in the menu is the merger of both, but non-admin users cannot remove the entries coming from the All-user part.
You actually don't have to do anything for this, though. Users can copy your normal shortcut to the Startup menu themselves. Hence, any program can be an auto-startup program. Doesn't need to be C++ at all.
There are many ways to autostart an application, but the easiest, most common and IMO best are:
- Put a shortcut in the autostart folder
- Add an autostart entry to the registry (Software\Microsoft\Windows\CurrentVersion\Run)
The end result is the same for both. I believe the registry way is executed earlier in the logon process than the startup way, but I am not certain. It does not make any difference for most cases anyway. I prefer the registry, but that is personal taste. You can create and delete the registry key or the shortcut programatically in your app.
With both options you can use either one setting for all users (All User startup folder, or under HKLM key in the registry) or user specific (user startup folder or under HKCR key).
In general it is better to use the per user options, because you can be certain to have writing privileges in those areas; and every user on the computer can have his/her own setting.
You can register it as a windows service.You can use "Qt Solutions" for easily making an application as windows service.