0

In my C# WPF application, I am setting an application as a startup application by creating a new key in the startup registry as follows:

RegistryKey startapp = Registry.CurrentUser.OpenSubKey("SOFTWARE\\Microsoft\\CurrentVersion\\Run", true);
startapp.SetValue("Myexe.exe", Aseembly.GetExecutingAssembly().Location);
Process.Start("Myexe.exe", url);

This runs fine and the registry value gets set, as checked in regedit. The user ought to have administrative privileges for setting the registry.

Also, the problem is that on rebooting the computer, I noticed that the application runs on startup only if the User Account Control has been turned off (with least security), and not the default settings. This is not the case for other applications such as Google Talk etc. in my computer? So, how do I allow my application to run at startup, even if the user account control UAC settings are bit high?

user7116
  • 63,008
  • 17
  • 141
  • 172
user1240679
  • 6,829
  • 17
  • 60
  • 89

1 Answers1

0

You might want to try adding an application manifest to your application to indicate the application requires administrative privileges to run. See this related SO Question for more details: UAC need for console application.

Community
  • 1
  • 1
Tim Lentine
  • 7,782
  • 5
  • 35
  • 40
  • I am an administrator on this machine. Last things I noticed was that the registry is there (as seen in regedit). If the UAC is turned off, the application does run at startup. However, if the UAC settings are as in default, this does not run the application at sratup. Adding the manifest to my app would affect this thing to get this running while UAC settings are default? – user1240679 Mar 29 '12 at 17:47
  • Another thing: In the same registry path, there are other applications such as Forefront TMG Client, etc. which run even if the UAC settings are default – user1240679 Mar 29 '12 at 17:48
  • @user1240679: I don't know much about those other products, but I would guess they are doing something similar. Vista \ Win 7 are a bit different when it comes to UAC. Even if you are logged on as a local admin there are still some functions you need to explicitly request elevated permissions for. – Tim Lentine Mar 30 '12 at 12:57