How Do I Get System Account Permissions or run app with system rules in C# -
i want remove sections registry system\currentcontrolset\enum\usb, cant delete properties (windows10)
string user = environment.userdomainname + "\\" + environment.username; registrysecurity msec = new registrysecurity(); registrysecurity msec = new registrysecurity(); registryaccessrule newrule = new registryaccessrule( user, registryrights.fullcontrol, inheritanceflags.objectinherit | inheritanceflags.containerinherit, propagationflags.none, accesscontroltype.allow); registrykey hkusb = hklm.opensubkey(registrypath, registrykeypermissioncheck.readsubtree); registrysecurity security = hkusb.getaccesscontrol(); if (containsrule(security.getaccessrules(true, true, typeof(securityidentifier)), newrule)) { console.writeline("access"); console.readkey(); return; } security.addaccessrule(newrule); hkusb.setaccesscontrol(security); <----error here hkusb.close(); showkeytree(hkusb, "+"); console.readkey();
this code allows me delete sections exept properties
i understand iam need system permissions this, dont know how make in code. p.s. need start process system psexec, in code
Comments
Post a Comment