I need to delete a key from a command line. So I wanted to use reg delete "the key to be deleted" /f but I get ERROR: access is denied.

From the same login session (the same user) I am able to delete the key without any troubles from regedit.exe that is not run as administrator.

I cannot use runas command to execute reg that I believe would be to solution because in fact I want to use reg to delete registry entry for administrator profile so runas works again. More info in my other question Windows7 corrupted profile - prevention exists?

  • Regedit.exe always runs as administrator. How'd you manage to run it without it? Why isn't deleting it with Regedit enough to solve your Runas problem? – Ƭᴇcʜιᴇ007 Oct 18 '12 at 23:12
  • I need to delete the key from command line. – Radek Oct 18 '12 at 23:15
  • 2
    @Ƭᴇcʜιᴇ007 Regedit.exe always runs as administrator - that's simply wrong! – Wolf Jan 15 '15 at 8:45

Administrative commands need to run from an elevated command prompt. Standard command prompts in Windows Vista and newer don't run with administrator rights even if the user is an administrator.


REG.exe opens the registry hive with "AllAccess" and in case ACLs do not give credentials to the registry hive the REG.exe is unable to delete it.

But when you try to delete the same hive with regedit, there is no problem. This is because RegEdit opens the registry with less required credential swithches. Registry Key Security and Access Rights If you know what to delete then the best option is to use regedit from command prompt: regedit /s deleteHive.reg

Look more details from MS: How to add, modify, or delete registry subkeys and values by using a .reg file

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.