19

Is it possible to programmatically disable UAC in Vista? Or, can I make my application run unrestricted by the UAC setting in any way? FYI, the application needs to mount hard drives on the fly, which is why I can't ask for UAC permission each time...

Update:

I'm looking for something in line with what Kosi2801 mentioned, basically to ask the user to always start the program in an 'elevated' mode. I'd want the permission to be a 1 time thing, I'm not saying that I programmatically disable UAC without asking permission first. I'm sure there are lots of programs that need to operate in this mode (especially hardware-related programs) so there should be some type of way to accommodate it.

Abdullah Jibaly
  • 53,220
  • 42
  • 124
  • 197
  • The correct solution is to install a service to do the admin-level tasks on your behalf. – Harry Johnston May 08 '14 at 21:43
  • I created a service based application to turn off UAC, take a look at my answer. – Zach Leighton May 14 '15 at 19:17
  • If you can program in c#, you may get help from http://stackoverflow.com/questions/682182/disabling-uac-programmatically – Sami Aug 15 '16 at 16:34
  • The UAC is the user's preference; not yours. You also have to consider that disabling UAC doesn't solve your problem. When the user is a standard user, the program still won't run with administrative privileges. You have to ask yourself: what would you have done on Windows XP? The user is a standard user, you have to deal with it correctly. – Ian Boyd Sep 25 '18 at 19:26

8 Answers8

18

Set the EnableLUA DWORD value in HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System to 0 and reboot.

this will disable UAC without a problem, i would do it to all your users, with or without permission is up to you, because the vista UAC is so horrid that i do believe the less people that have it on the better (in vista only) it is now better in win7.

have fun with my registry trick :)

works in win7 as well, let me know how you got along with it.

Erx_VB.NExT.Coder
  • 4,838
  • 10
  • 56
  • 92
  • UAC is in fact broken in several ways. I can see why some otherwise correct programs would fail rather spectacularly when UAC is enabled. – Joshua Jul 29 '10 at 15:17
  • 1
    +1 for the trick, but would UAC let us modify the registry value in HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System without warning the user on the recieving end? – Omair Iqbal Aug 07 '10 at 05:54
  • 1
    well, as long as you are running the program (exe) under admin (ie person running app has accepted to run it as admin) then you actually can do the registry trick without the user being told anything, in VISTA, in Win7, you can still do it, but user will get notification saying 'you need to restart your computer in order for UAC to take effect' - this doesn't interupt the process, just implies to user that disabling occured... but if you want, you can turn that msg off as well with another registry trick :), so, it always 'works' as long as running as admin. – Erx_VB.NExT.Coder Aug 10 '10 at 22:28
  • i also suggest you mark this as the answer, since every other answer was vhastly misinformed in my opinion – Erx_VB.NExT.Coder Aug 10 '10 at 22:33
  • 11
    Disabling UAC globally for the whole computer just to make one (avoidable) issue easier for a single application? Why not just also de-install all Virus-Scanners because the warn you too often? Lowering security to enhance usability is never a solution in my opinion. – Kosi2801 Aug 12 '10 at 08:17
  • 2
    I think this is technically the correct answer, however I would not recommend anyone using this approach since it pretty much defeats the purpose of UAC as stated by others here. It may be ok if you're doing it in your own/internal/corporate environment... – Abdullah Jibaly Nov 29 '10 at 17:02
  • Thank you, yes I agree this is a last resort option. – Erx_VB.NExT.Coder Nov 30 '10 at 07:12
  • Yes it working as just avoid the dialog box, but if the user has admin rights it took "Yes" otherwise "No" by defaul – Singaravelan Jul 02 '14 at 04:44
  • You are missing the 3 other registry keys that need to be set. – Zach Leighton May 14 '15 at 19:16
15

You can't programmatically disable UAC, but you can force the program to run with elevated privileges from the start, so it doesn't prompt each time.

That will cause it to prompt once on startup, but not each time it needs access.

To do this, you'll need to create a manifest file and set <requestedExecutionLevel level="requireAdministrator">

See MSDN for details.

Reed Copsey
  • 554,122
  • 78
  • 1,158
  • 1,373
  • Hi Reed, I am making an installer(which has the above permissions) which runs ServiceModelReg.exe, but it ends with an error...whereas running it with manually elevating permissions from Control panel...every thing works fine – taher chhabrawala Jul 30 '10 at 09:46
  • read my answer, you can disable UAC as long as you are running under admin priviledge! – Erx_VB.NExT.Coder Aug 10 '10 at 22:32
  • @Erx_VB.NExT.Coder: That forces a reboot, though. It isn't what I'd call a programatic change, but a configuration change. It really doesn't help, since the user could just change the systme config in that case. – Reed Copsey Aug 11 '10 at 02:00
  • I'm just annoyed that everyone is saying disabling UAC is impossible when that in fact is not true at all. Misinformation is the problem. You can disable uac using the registry if ur in admin or elevated mode which most running apps are. – Erx_VB.NExT.Coder Nov 29 '10 at 01:23
  • @Erx_VB.NExT.Coder: You can do it (provided you have elevated permissions) for the entire user account, but not for a specific operation/process. It also requires elevated permissions (ie: a UAC prompt) in order to do... – Reed Copsey Nov 29 '10 at 16:59
9

The purpose of UAC is to prevent executing unwanted applications. If it was possible to disable it programatically it would be worthless.

jkottnauer
  • 403
  • 9
  • 18
3

I posted a somewhat granular (but ugly) solution here

http://stackoverflow.com/questions/5344021/bypass-uac-in-vbscript/34445992#34445992

It only works if you can kick off the application from the task scheduler. I have it running on two Windows 7 laptops. It is an administrative solution. You need administrator privilege to implement it. I use it for powershell and for my UPS power backup application. I suspect I'll find other uses.

Jia Jian Goi
  • 1,415
  • 3
  • 20
  • 31
  • Is there some particular reason for the negative rating? My solution disables UAC in a way that has not be published anywhere else I have seen. It is a problem I've been tryig to solve for 3 years. The solution works. – namrokretep Dec 26 '15 at 04:14
1

I created a small application to do this, but basically there are 4 registry keys you need to set.

C# example:

Microsoft.Win32.Registry.SetValue("HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Policies\\System","EnableLUA", 0);

Microsoft.Win32.Registry.SetValue("HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Policies\\System", "ConsentPromptBehaviorAdmin", 0);

Microsoft.Win32.Registry.SetValue("HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Policies\\System", "PromptOnSecureDesktop", 0);

Microsoft.Win32.Registry.SetValue("HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\CurrentVersion\\Action Center\\Checks\\{C8E6F269-B90A-4053-A3BE-499AFCEC98C4}.check.0", "CheckSetting", StringToByteArray("23004100430042006C006F00620000000000000000000000010000000000000000000000"), RegistryValueKind.Binary);

My application runs as a service every 5 minutes to "fight" Group Policy on this, which is an absolute annoyance for a developer machine.

https://github.com/zleight1/DisableUAC

Zach Leighton
  • 1,939
  • 14
  • 24
0

UAC is a necessary evil alike the use of semaphores on a city. I suggest adapting to the new paradigm. I personally don't like UAC; but I understand the purpose and benefits. Unfortunately, we all created this monster. Lest's go back to 1983, do a short assessment of the changes throughout the years and then, we will understand. Of course, if the intent is for private use, anything is possible, as pointed above; but it would be risky and become a black hole liability.

0

Disabling UAC programmatically would defeat its purpose as this would then also be possible to be done by malware, worms, trojans and virusses and have no real security-effect at all.

You could require to run your application under the admin-account or (I think) let Microsoft somehow sign your application.

There may be other ways I'm not aware of, but none of them is programmatically!

Kosi2801
  • 22,222
  • 13
  • 38
  • 45
  • of course you can disable UAC and any accompanying message related to it as long as you are running the program under admin priviledge! – Erx_VB.NExT.Coder Aug 10 '10 at 22:30
  • Since the question was related to currently having the application being started in a restricted way it would not be possible under that conditions. Of course, as I said too, requiring it to be started with admin-privileges would do the trick. And since it shouldn't have to happen manually each time the answer still applies. So the accepted answer, how to automatically start the elevated mode is correctly chosen. – Kosi2801 Aug 12 '10 at 08:13
  • I believe my answer was updated as the correct answer, which was correctly chosen as they asked how to get rid of the uac problem, and that's what it does. Last resort I agree but it's accurate. He changed accepted answer to my answer. – Erx_VB.NExT.Coder Dec 25 '10 at 08:49
-1

That would defeat the object of UAC. So no, you can't.

blowdart
  • 55,577
  • 12
  • 114
  • 149