I am trying to launch automatically my application when I turn on the computer. I've wrote this program into my code :
if (Convert.ToInt32(_param.AUTOMATIC_LAUNCH) == 1)
{
registryKey = Registry.CurrentUser.OpenSubKey("Software\\Microsoft\\Windows\\CurrentVersion\\Run", true);
registryKey.SetValue("Quick", Process.GetCurrentProcess().MainModule.FileName.ToString());
}
if (Convert.ToInt32(_param.AUTOMATIC_LAUNCH) == 0 && registryKey != null)
{
registryKey.DeleteValue("Quick", true);
}
The key is indeed in the folder : "Software\Microsoft\Windows\CurrentVersion\Run". But I have a this message which appears in my log :
System.UnauthorizedAccessException: access to the path 'C:\WINDOWS\System32\config_borne.ini' denied.
at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath) (....)
I've tried to grant autorization to the user in the folder of my application but it doesn't work. In addition, the "config-borne.ini" is a file which doesn't exist.