Launch a C # application on Windows startup

I try to run several applications for the current user only when Windows starts.

I can accomplish this with the following:

RegistryKey oKey = Registry.CurrentUser.OpenSubKey("Software", true); oKey = oKey.OpenSubKey("Microsoft", true); oKey = oKey.OpenSubKey("Windows", true); oKey = oKey.OpenSubKey("CurrentVersion", true); oKey = oKey.OpenSubKey("Run", true); oKey.SetValue("Application 1", "C:\\path\\to\\ap1.exe"); oKey.SetValue("Application 2", "C:\\path\\to\\ap2.exe"); 

But I'm trying to run this as part of a Visual Studio installer project. I added my own action, the program starts as it should, and the installer works fine in XP.

On Windows 7, the installer receives elevated privileges and does everything except insert registry entries for the current user. Be that as it may, it inserts registry entries at startup as a stand-alone application (outside the installer project) and does not receive elevated privileges.

The only thing I can understand is that with elevated privileges, is he trying to insert entries into the Administrators account instead of the current user? or is there something else that i'm missing? and is there any other way that I can achieve my goal here?

+7
source share
2 answers

Is there a reason not to use the boot folder for the user?

Most likely, the problem is that the user is executing the installer. If the user is not an administrator, the elevated installer will be launched in the context of the user who enlarged the process.

It would be safer to add the application to the startup folder or add the registry key on first launch.

+2
source

If the installer gets elevated permissions, why write this parameter to HKCU? Instead, write it to HKLM. It will be valid for all users.

+1
source

All Articles