2

hey I'm trying to launch an app on the startup I have always done it just fine by using this code :

RegistryKey rkApp = Registry.CurrentUser.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", true);
if (rkApp.GetValue("Folder Locker") == null)
{
    rkApp.SetValue("Folder Locker", Application.ExecutablePath.ToString());
}

But now when I do this:

requestedExecutionLevel level="requireAdministrator" uiAccess="false" 

to start as administrator the app doesn't start on the start up I need help I hope it would be a small problem and not a big deal.

tshepang
  • 12,111
  • 21
  • 91
  • 136
Aodai Irshed
  • 230
  • 1
  • 11
  • 3
    Generally, normal applications shouldn't need admin rights, which is why UAC would prompt for them, when running an app - it may be better to consider an alternative approach, like running as a windows service, and doing any IPC as required – Rowland Shaw Jan 18 '14 at 21:16
  • http://superuser.com/a/537101/198092 this question really belongs on SuperUser - and is a duplicate on SO and SuperUser – phil soady Jan 18 '14 at 23:53

1 Answers1

3

You cannot get an application to run at logon that will elevate and somehow bypass the UAC dialog. That would pretty much defeat the purpose of UAC.

Your options include:

  • Accepting that the user will be prompted for elevation.
  • Modifying your application so that it does not require elevation. If some operations require elevation, then start a new elevated process to perform those tasks
  • Running your process as service in session 0 where UAC does not apply.
David Heffernan
  • 601,492
  • 42
  • 1,072
  • 1,490