2

I've been wrestling with this issue for a few days and can't find any posts that solve it for me. Maybe what I want isn't possible.

We have developed a WinForms application for internal use at our company.

Most employees do not have admin access in windows.

Our application requires admin access to the machine and needs to automatically start when the user logs on.

Here's what I've tried:

1) Putting a Shortcut in the Startup folder

I can get the app to automatically launch (using a relauncher), but it still requires an admin to be at the computer on every restart (to enter the password).

2) Registry Key

I created a Software\Microsoft\Windows\CurrentVersion\Run registry key to automatically start the application. Whether I run the relauncher or the app itself, UAC demands a password on every restart (or relogin).

3) Scheduled Task

I created a scheduled task to automatically start the app on logon using admin permissions on the machine (under use the following account). I also checked the 'Run with highest privileges' box. UAC still pops up on every restart.

4) Windows Service

I tried to run the app as a windows service, but it has a user interface (which is disabled by windows services).

5) Disable UAC for Specific Program

It looks like you can disable UAC for a specific program but that involves downloading the Application Compatibility Toolkit, creating some kind of database, etc. I'd very much prefer that our IT staff wouldn't have to do that at every machine. At this point, it's probably my only option.

It seems like an admin should be able to install an application so that it runs automatically without a prompt. Am I missing a way to do this?

Community
  • 1
  • 1
bendytree
  • 13,095
  • 11
  • 75
  • 91

4 Answers4

5

You should make split your program into a non-admin UI, which runs on user startup, and an admin service, which performs the administrative tasks.

To run admin-requiring code from the UI, use WCF to ask the service to do it.

Beware that hostile parties may impersonate the UI and ask the service to do malicious things; you need to carefully figure out what the service should be able to do in response to IPC calls.

SLaks
  • 868,454
  • 176
  • 1,908
  • 1,964
1

Your problem is not a UAC problem, it is a security problem.

And the answer depends on what your application that "requires admin rights" needs to do.

  • If your application needs to be able to start, and stop services, then the User needs the ability to start and stop services. In which case you need to give the users that privilege.
  • If the user's need the ability to alter or delete files, then they need that privilege too. In that case it is easier to grant Full Control permissions to Everyone.
  • If your application needs the ability to modify registry keys in the HKLM tree then you can, again, grant Full Control to Everyone in the registry.

If you need your users to have the ability to modify items, then they need permissions to modify those locations. Granting them those NTFS permissions is not a bad thing; it is exactly what those permissions exist for - to control access.

But why

But then we ask why? What is it you're doing that users need all the rights of an administrator, and all capabilities of an administrator, all the power of an administrator, but you don't want to make them a member of the Administrator's group?

The answer is almost invariably that your internal use application doesn't need to run as an administrator.

What Would XP Do?

The question becomes:

What would you do on Windows XP?

A standard user on Windows XP didn't even have the UAC convenience feature. If a user wanted to run an application an administrator: they had to logout and login as an administrator. How did, or how would, the application work on a system with UAC disabled?

Ian Boyd
  • 246,734
  • 253
  • 869
  • 1,219
0

Presumably very little of your application needs to run as admin - the rest would be better running as the unprivileged user. This is very common (think self-updating browsers, for example).

The proper way to do this is to install a service to do the privileged bit, and have the UI communicate with the service.

Will Dean
  • 39,055
  • 11
  • 90
  • 118
0

Our application requires admin access to the machine ...

Why?

You cannot bypass the UAC prompt, and this is by design.

See FAQ: Why can’t I bypass the UAC prompt? for a good discussion of why. Excerpt:

If it were possible to mark an application to run with silently-elevated privileges, what would become of all those apps out there with LUA bugs? Answer: they'd all be marked to silently elevate. How would future software for Windows be written? Answer: To silently elevate. Nobody would actually fix their apps, and end-user applications will continue to require and run with full administrative permissions unnecessarily.

Bill_Stewart
  • 22,916
  • 4
  • 51
  • 62