Click here to Skip to main content
15,905,144 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

I am writing program installer using VB.Net and I am facing difficulty in disabling UAC to complete the installaion.
Here is the code that I am using it to disable the UAC:

VB
Dim regKey As RegistryKey
        Dim ver As Decimal
        Dim keyst As String = "Software\Microsoft\Windows\CurrentVersion\Policies\System"
        regKey = Registry.LocalMachine.OpenSubKey(keyst, True)
        ver = regKey.GetValue("EnableLUA", 0.0)
        If ver = 1.0 Then
            regKey.SetValue("EnableLUA", 0)
            'My.Computer.Registry.SetValue("HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Policies\System", "EnableLUA", 0)
        End If
        MsgBox(regKey.GetValue("EnableLUA"))
        regKey.Close()


I am attempting to write values to the registry, but get an
UnauthorizedAccessException when I try to do a SetValue on an existing key.

Any help please :)
Posted
Updated 20-May-10 9:39am
v3
Comments
Dalek Dave 20-May-10 15:33pm    
Edited for readability

Gee - UAC would be super useful if it only protected people from programs written by peopel who didn't know how to just turn it off.

UAC is a joke, but it's obvious to me that you can't turn it off in code.
 
Share this answer
 
You need to have administrator rights, is typically how it works.
 
Share this answer
 
Yes Gras;
I couldn't disable it in code...
 
Share this answer
 
v2
Comments
Christian Graus 20-May-10 15:51pm    
Please don't push 'answer' to make an inane comment. The comment button is there for that. Correct, you can't disable it in code. The end.
Christian Graus 20-May-10 15:52pm    
Reason for my vote of 1
Pushed 'answer' to add comments.

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900