[求助帖]咋用vb.net修改注册表项 HKLM\SAM\SAM 的权限
vb.net吧
全部回复
仅看楼主
level 8
各种拒绝访问。
我要改的权限也就是右键注册表项,权限里面
俗称安全选项卡
跟文件的安全选项卡类似
我就是要用vb.net改注册表项HKLM\SAM\SAM的权限 完全控制
我的代码:
Sub Main()
Console.ForegroundColor = ConsoleColor.DarkCyan
Console.WriteLine()
Dim CrtWP As System.Security.Principal.WindowsPrincipal = New System.Security.Principal.WindowsPrincipal(Security.Principal.WindowsIdentity.GetCurrent)
If CrtWP.IsInRole(Security.Principal.WindowsBuiltInRole.Administrator) Then
Console.WriteLine("[+][Administrator]当前登录Windows账户:" & Security.Principal.WindowsIdentity.GetCurrent.Name)
ElseIf CrtWP.IsInRole(Security.Principal.WindowsBuiltInRole.User) Then
Console.WriteLine("[+][User]当前登录Windows账户:" & Security.Principal.WindowsIdentity.GetCurrent.Name)
Else
Console.WriteLine("[+][Unknown]当前登录Windows账户:" & Security.Principal.WindowsIdentity.GetCurrent.Name)
End If
Console.ForegroundColor = ConsoleColor.DarkGreen
Console.WriteLine()
Try
Using RegKey As RegistryKey = Registry.LocalMachine.OpenSubKey("SAM")
Dim RegkeyAcl As RegistrySecurity = RegKey.GetAccessControl()
Dim AccessRule As RegistryAccessRule = New RegistryAccessRule(Security.Principal.WindowsIdentity.GetCurrent.User, RegistryRights.FullControl, AccessControlType.Allow)
RegkeyAcl.AddAccessRule(AccessRule)
RegKey.SetAccessControl(RegkeyAcl)
End Using
Console.WriteLine("[+]应用注册表权限成功!")
Catch ex As Exception
Console.ForegroundColor = ConsoleColor.Red
Console.WriteLine("[-]设置注册表权限时发生错误:" & ex.Message)
End Try
Console.ReadKey()
End Sub
运行效果:
出错代码这一行:
设置其他注册表项权限都很顺利,没有这么多问题,就是这个HKLM\SAM\SAM比较特殊啊,失败的原因肯定不是权限问题,在注册表编辑器里是可以改的,但我的程序各种问题,求吧里大牛帮忙看一下。。不要问我改SAM权限干什么用[滑稽]
2015年11月07日 10点11分 1
level 8
2015年11月07日 10点11分 2
level 8
就是要改这里,能把完全控制打上勾,然后就可以展开SAM项,读写里面的数据了
注册表编辑器可以改,但我要用程序实现怎么办
2015年11月07日 10点11分 3
level 12
注册表可以用vb写。。具体我记不住了 你查查
2015年11月07日 11点11分 4
我是要改注册表项的访问权限。。注册表谁都会改
2015年11月07日 11点11分
level 13
看那些c++代码怎么写的就明白了
---贴吧极速版 For UWP
2015年11月08日 10点11分 5
1