本文介绍了如何设置属于系统帐户的所有者子项?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何设置属于系统帐户的所有者子项?
How set owner subkey which belongs System account?
如果此代码:
var rs = new RegistrySecurity();
var rk = Registry.ClassesRoot.OpenSubKey(subkey, RegistryKeyPermissionCheck.ReadWriteSubTree, RegistryRights.TakeOwnership);
var admin = WindowsIdentity.GetCurrent().Name;
rs.SetOwner(new NTAccount(admin));
rk.SetAccessControl(rs);
Console.Write(rk.Name);
两行异常.
如果此代码:
var rs = new RegistrySecurity();
var rk = Registry.ClassesRoot.OpenSubKey(subkey, RegistryKeyPermissionCheck.ReadWriteSubTree, RegistryRights.ReadPermissions);
var admin = WindowsIdentity.GetCurrent().Name;
rs.SetOwner(new NTAccount(admin));
rk.SetAccessControl(rs);
4行中的System.UnauthorizedAccessException.
System.UnauthorizedAccessException in 4 line.
推荐答案
由于该问题与脚本相关,因此建议在脚本论坛以获得更好的帮助.
As the question is related to Scripting, it is recommended to address the question inScripting Forums for better assistance.
感谢您的理解.
Thanks for your understanding.
问候.
Regards.
这篇关于如何设置属于系统帐户的所有者子项?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!