I am writing a custom Windows setup program, and all has gone well to this point. I have working code that allows the program being installed to show in the Windows "Add/Remove Programs window. When I attempt to uninstall the program in the normal way from the Add/Remove Programs window I get an error, "You do not have sufficient access to uninstall [my program name]…. After some digging I concluded I need to grant privileges to the key …/uninstall/[my program name]. I put together some code in an attempt to grant privileges but it does not work. What am I doing wrong? I have included my code in "obsolete" VB below. Thanks for helping me. Code: Private Sub TestKeys() Dim registrySearchKey As RegistryKey registrySearchKey = RegistryKey.OpenBaseKey(RegistryHive.LocalMachine, RegistryView.Registry32).OpenSubKey("SOFTWARE") _ .OpenSubKey("Microsoft").OpenSubKey("Windows").OpenSubKey("CurrentVersion").OpenSubKey("Uninstall") For Each ValueName In registrySearchKey.GetSubKeyNames If ValueName = "TimeTracker" Then Dim registryKeyToAlter As RegistryKey registryKeyToAlter = registrySearchKey.OpenSubKey("TimeTracker") Try Dim rs As RegistrySecurity = New RegistrySecurity() Dim user As String = Environment.UserDomainName & "\" & Environment.UserName rs.AddAccessRule(New RegistryAccessRule(user, RegistryRights.WriteKey, InheritanceFlags.ContainerInherit, PropagationFlags.InheritOnly, AccessControlType.Allow)) registryKeyToAlter.SetAccessControl(rs) MsgBox("Key Permission was set.") Catch ex As UnauthorizedAccessException MsgBox("Error: " & ex.Message) End Try End If Next End Sub
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)