cookie_monster Posted March 4, 2010 Posted March 4, 2010 Is there a special way to remove a reg key from classes root? I have a script that works fine when removing keys from HKLM but it fails to delete a key in HKCR. The first two entries are deleted every time but the third errors saying 'Unable to remove registry key' 80070002. I can remove the key using regedit so it's not being held open. On Error Resume Next Dim WshShell, bKey Set WshShell = WScript.CreateObject("WScript.Shell") WshShell.RegDelete "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Run\IgfxTray" WshShell.RegDelete "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Run\HotKeysCmds" WshShell.RegDelete "HKCR\Directory\Background\shellex\ContextMenuHandlers\igfxcui" set WSHSHell = Nothing wscript.quit Thanks.
srochford Posted March 4, 2010 Posted March 4, 2010 Try: WshShell.RegDelete "HKLM\software\classes\Directory\Background\shellex\ContextMenuHandlers\igfxcui" but I think HKCR should work (HKCR is just an alias to the "real" location) Error 0x80070002 means "not found" so are you sure of the spelling??
cookie_monster Posted March 4, 2010 Author Posted March 4, 2010 (edited) Sorted it, I needed a trailing slash at the end to delete subkeys. WshShell.RegDelete "HKCR\Directory\Background\shellex\ContextMenuHandlers\igfxcui\" Edited March 4, 2010 by cookie_monster
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now