I have a C# application and I want to add this application to start-up. I use:
RegistryKey Key = Registry.CurrentUser.OpenSubKey(@"Software\Microsoft\Windows\CurrentVersion\Run", true);
Key.SetValue("APPName", "C:\\Program Files\\App\AppName.exe");
My application need Administrator Right to run, I want a method to register my app or to add to trusted applications.
Thanks.
Now I'm using:
var info = new ProcessStartInfo(
Assembly.GetEntryAssembly().Location)
{
Verb = "runas", // indicates to elevate privileges
};
var process = new Process
{
EnableRaisingEvents = false, // enable WaitForExit()
StartInfo = info
};
process.Start();
For obtain access only for one method, but now I have problem with
unauthorizedAccessException was unhandled
I'm trying to create a directory in C:\Program Files.