{"record":{"id":"4dec7f0e1030e67f","repo":"BCUninstaller/Bulk-Crap-Uninstaller","slug":"key-fullregkeypath-doesn-t-exist-or-can-t-be-a","errorCode":null,"errorMessage":"Key \"{FullRegKeyPath}\" doesn't exist or can't be accessed","messagePattern":"Key \"(.+?)\" doesn't exist or can't be accessed","errorType":"exception","errorClass":"IOException","httpStatus":null,"severity":"warning","filePath":"source/UninstallTools/Junk/Containers/RegistryKeyJunk.cs","lineNumber":57,"sourceCode":"        public override void Backup(string backupDirectory)\r\n        {\r\n            var fileName = PathTools.SanitizeFileName(FullRegKeyPath.TrimStart('\\\\')) + \".reg\";\r\n            var path = Path.Combine(CreateBackupDirectory(backupDirectory), fileName);\r\n            RegistryTools.ExportRegistry(path, new[] { FullRegKeyPath });\r\n        }\r\n\r\n        public override void Delete()\r\n        {\r\n            using (var key = RegistryTools.OpenRegistryKey(RegKeyParentPath, true))\r\n            {\r\n                key?.DeleteSubKeyTree(RegKeyName);\r\n            }\r\n        }\r\n\r\n        public override void Open()\r\n        {\r\n            if (!RegKeyExists())\r\n                throw new IOException($\"Key \\\"{FullRegKeyPath}\\\" doesn't exist or can't be accessed\");\r\n\r\n            RegistryTools.OpenRegKeyInRegedit(FullRegKeyPath);\r\n        }\r\n\r\n        public override string GetDisplayName()\r\n        {\r\n            return FullRegKeyPath;\r\n        }\r\n    }\r\n}","sourceCodeStart":39,"sourceCodeEnd":67,"githubUrl":"https://github.com/BCUninstaller/Bulk-Crap-Uninstaller/blob/608321de98e92297377b1eb69029af55c25504a1/source/UninstallTools/Junk/Containers/RegistryKeyJunk.cs#L39-L67","documentation":"Thrown by RegistryKeyJunk.Open() when RegKeyExists() returns false before attempting to open the key in regedit via RegistryTools.OpenRegKeyInRegedit. The junk-removal subsystem treats registry keys as disposable 'Junk' entries, and Open() is the user-facing 'show me this in regedit' action. It refuses to launch regedit for a key that has already been removed or that the current user cannot read.","triggerScenarios":"Calling Open() on a RegistryKeyJunk instance whose underlying key was deleted by a previous cleanup step, or whose hive/ACL denies the current user read access. Also happens if the key path is constructed from stale uninstaller metadata.","commonSituations":"A registry junk entry is enumerated, the user deletes it (Delete() runs), then double-clicks/opens it again; or another process/uninstaller removed the key between enumeration and the Open() call; or the app is run under an account that cannot read HKLM\\SYSTEM\\* subkeys.","solutions":["Call RegKeyExists() (or wrap Open() in try/catch IOException) before exposing an Open action in the UI, and disable/hide the action when false.","Re-enumerate the junk list before opening so stale entries are dropped.","If running elevated still fails, check the key's ACL with regedit/Get-Acl and grant the calling principal read access."],"exampleFix":"// before\njunkEntry.Open();\n\n// after\nif (junkEntry is RegistryKeyJunk rk && !rk.RegKeyExists())\n{\n    // refresh list / inform user the key is gone\n    return;\n}\njunkEntry.Open();","handlingStrategy":"validation","validationCode":"// Before opening a registry junk entry\nif (junkEntry is RegistryKeyJunk rk && !rk.RegKeyExists())\n{\n    OnStaleEntry(rk);\n    return;\n}","typeGuard":"null","tryCatchPattern":"try { junkEntry.Open(); }\ncatch (IOException ex) when (ex.Message.Contains(\"doesn't exist or can't be accessed\"))\n{\n    // entry was removed between enumeration and open; refresh the list\n    RefreshJunkList();\n}","preventionTips":["Re-enumerate the junk list immediately before exposing per-entry Open actions.","Disable the Open command in the UI when RegKeyExists() is false.","Run the app elevated when keys under HKLM\\SYSTEM are involved."],"tags":["registry","windows","io-exception","access-control","junk-removal"],"backgroundTag":null,"analyzedSha":"608321de98e92297377b1eb69029af55c25504a1","analyzedAt":"2026-08-13T12:17:35.389Z","schemaVersion":2},"datasetVersion":"2026-08-13T14:17:21.547Z"}