Page 1 of 1
Can't delete registry key
Posted: 29 Aug 2019, 03:18
by user549
I am on Windows 10 64 bit. I can't delete this registry key though i can manually delete it using Regedit.exe. This is the code:
Code: Select all
RegDelete, HKEY_CLASSES_ROOT\MbHwgGGS1
Please help. Thanks.
Re: Can't delete registry key
Posted: 30 Aug 2019, 02:40
by gregster
Did you try to run the script 'as admin' ? I could imagine that deleting registry keys requires elevated rights on most systems...
Re: Can't delete registry key
Posted: 31 Aug 2019, 04:08
by user549
Yes, I did. But it did not work.
It seems the script can delete the keys under HKEY_CURRENT_USER branch only.
Any ideas? Thanks.
Re: Can't delete registry key
Posted: 31 Aug 2019, 04:25
by gregster
According to the
RegDelete docs,
HKEY_CLASSES_ROOT keys should generally be accessible/deletable.
I would add these lines immediately after your RegDelete attempt:
Code: Select all
msgbox % ErrorLevel
msgbox % A_LastError
Errorlevel is probably
1 in your case, but the
A_LastError might give you some error code that you (or we) might be able to decode with the help of the Microsoft docs on the internet. Ideally, you can then take countermeasures, depending on the actual problem.
Since you are on a 64-bit system, this might be an issue:
To delete entries from the 64-bit sections of the registry in a 32-bit script or vice versa, use
SetRegView.
Re: Can't delete registry key
Posted: 31 Aug 2019, 06:43
by user549
I tried this:
Code: Select all
SetRegView 32
;SetRegView 64
RegDelete, HKEY_CLASSES_ROOT\MbHwgGGS1
msgbox % ErrorLevel
msgbox % A_LastError
I still see the ErrorLevel is 1, A_LastError is 5 (ERROR_ACCESS_DENIED, according to this
https://docs.microsoft.com/en-us/windows/win32/debug/system-error-codes--0-499-)
What should I do now? Thanks.
Re: Can't delete registry key
Posted: 31 Aug 2019, 07:30
by gregster
Are there subkeys? It seems that in some cases you need to delete all subkeys before you can delete the main key.
There is
Loop (Registry) to loop through keys. (Again try also as admin.)
Re: Can't delete registry key Topic is solved
Posted: 31 Aug 2019, 08:52
by user549
Thanks for your help.
I reinstall Autohotkey. Certainly, must run the script as Admin for it to work, there is no need to use SetRegView.
Thanks, again, gregster and the others for your help.