Create autorun registry key (run application with Windows start)

To run your application automatically after Windows starts, you just need to create an entry in autorun registry key.
First of all, you must decide, if you want to run application for current user only or for all users (user accounts). In first case, use this registry key: HKEY_CURRENT_USERSoftwareMicrosoftWindowsCurrentVersionRun
and for all users, use this key: HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Run
This code will make autorun entry for all users:

 


To remove this entry, just call this procedure:

Sometimes, you just need to autorun your application just once (after first reboot of system). You can use these registry keys to achieve this:

HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnce

HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\RunOnce