Click here to Skip to main content
14,174,026 members
Rate this:
 
Please Sign up or sign in to vote.
See more:
I'm struggling to get my application to load without having a UAC popup window. My application does require admin access as I'm managing user accounts locally and with the domain on a 2008 server. My application is two parts, a service and a WPF app that controls the service.

I purchased a developer cert from Comodo and am able to sign the application. I also have a .manifest file assigned to the project.

After I build the application I see the shield on it so I know it's working ok. However, when I click on it I get a blue window asking if I want to allow the following program to make changes to this computer.

I believe my issue is around this line:
<requestedexecutionlevel level="requireAdministrator" uiaccess="false" />


If I set the level to asInvoker the UAC window doesn't appear but my app shuts down because of what it needs to operate.

Does anyone know how I can around this issue without disablign UAC?
Posted
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 1

You can't get rid of the UAC window.

When UAC is activated, any admin account will run WITHOUT admin priv's until they are actually needed. When that determination has been made by Windows, the UAC prompt window appears.

There's nothing you can do about it for your application. it's up to the user's admins to turn off UAC or set it to some other level in policy.
   
Comments
Sergey Alexandrovich Kryukov 11-Jul-12 22:37pm
   
How about so called "XP mode"? Or switching UAC off for the whole system? I would strongly discourage it though.
--SA
Dave Kreskowiak 11-Jul-12 23:42pm
   
Weeeelll, that depends on what his app is doing. XP Mode doesn't provide complete access to the Win7 host, so XP mode may let the app run, but it may also still be crippled by the wall between 7 and XP Mode.

Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 2

You can add a manifest to the application[^] that identifies the privileges for that program.
Save the file as ApplicationName.exe.manifest.
   
Comments
Sergey Alexandrovich Kryukov 11-Jul-12 22:37pm
   
Really? I though that the manifest will simply request some privileges by default, which could cause, in this case, the request through the UAC dialog be default, without specifying the option through the shell, *.lnk or any other way (and the default running without elevated privileges will simply throw exception during run-time at the moment of access violation). If I'm wrong, please explain it to me, perhaps I don't know something. There is a way to switch off the UAC totally or use so called "XP mode", which I would strongly discourage. I think Windows 7 is better than XP, and it provides quote reasonable balance between safety and the ease of use.
--SA
Sergey Alexandrovich Kryukov 11-Jul-12 23:17pm
   
Abhinav, I tried this thing with manifest and found that it works as I thought, please see above.
I think this makes your answer invalid. Tell me if I'm missing something.
Please see my answer which I put based on my simple experiments.
--SA
Abhinav S 11-Jul-12 23:25pm
   
If you are running the application with elevated privileges, the user will not see the UAC window.

It is not advisable to turn off the UAC.
Is that what the OP is looking for? That is not recommended.
Dave Kreskowiak 11-Jul-12 23:43pm
   
He's trying to suppress the UAC dialog without turning off UAC. Depending on how tight UAC is configured, it can't be done.
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 3

I do have a successful manifest being applied. If I change the line in the manifest from requireAdministrator to asInvoker the window goes away. But my app will not run because it requires administrator to do so. BTW Dave, I'm attempting to do more reading on what you have mentioned. Thanks.
   
v2
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 4

I found some references to running asInvoker then elevating the privileges from within the application with application.run(). Does anyone have any experience with that in Win7/2008?
   
Comments
Dave Kreskowiak 11-Jul-12 23:44pm
   
Doesn't work. You still get the UAC window when admin priv's are required.
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 5

Please see my comments to the answer by Abhinav. I tried to create a manifest and found that it works as I thought.

If you need elevated execution level "requireAdministrator", it will simply request your confirmation via the UAC dialog immediately and by default. If you do not request the elevated privileges but try to perform any operation which actually requires such privileges and do not execute the application with elevated privileges, you will simply get an exception at the moment of the illegal access.

It looks perfectly logical. If you could be able to do some miracle trick to work around UAC confirmation at the level of the application itself, based on the content of application's executable modules, it would totally defeat the purpose of UAC.

However, instructions to "disable UAC for certain applications" circulate. Please see:
http://www.wintuts.com/Disable-UAC-for-certain-applications[^].

I never tried it, but just because I consider UAC as of Windows 7 quite well balanced between ease of use and security.

The radical way to disable UAC is to disable it totally. You can find the related recipes here:
http://www.mydigitallife.info/how-to-disable-and-turn-off-uac-in-windows-7/[^].

I would strongly discourage doing so. Anyway, you decide.

—SA
   
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy | Cookies | Terms of Service
Web03 | 2.8.190524.3 | Last Updated 11 Jul 2012
Copyright © CodeProject, 1999-2019
All Rights Reserved.
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100