Windows – reg delete gives me “access is denied” but regedit delete is ok

command lineuser-profileswindows 7windows-registry

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?

Best Answer

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.

Related Question