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

  1. start code in new impersonate thread admin privileges: link
  2. impersonate current thread admin privileges: link

Comments

Popular posts from this blog

javascript - Chart.js (Radar Chart) different scaleLineColor for each scaleLine -

apache - Error with PHP mail(): Multiple or malformed newlines found in additional_header -

java - Android – MapFragment overlay button shadow, just like MyLocation button -