deleteKey
Category: Registry Operations
Namespace: web.registry.deleteKey
Description
Deletes an entire registry key and all its values under HKEY_CURRENT_USER. Use with caution.
Syntax
const success = await web.registry.deleteKey({
keyPath: 'Software\\MyApp\\OldSection'
});
Parameters
- keyPath (required) - Registry key path under HKEY_CURRENT_USER to delete
- rootKey (optional) - Currently ignored; always uses HKEY_CURRENT_USER
Returns
Promise<boolean> - Returns a promise that resolves with true if the key was deleted, false if it doesn't exist or deletion failed
Examples
Simple example
const success = await web.registry.deleteKey({
keyPath: 'Software\\MyApp\\TempData'
});
if (success) {
console.log('Key deleted successfully');
}
Remove old application data
// Delete entire settings section
const success = await web.registry.deleteKey({
keyPath: 'Software\\MyApp\\OldVersion'
});
if (success) {
console.log('Old version data removed');
}
Uninstall cleanup
// Remove all application registry data
const success = await web.registry.deleteKey({
keyPath: 'Software\\MyApp'
});
if (success) {
console.log('Application registry data removed');
} else {
console.log('No registry data found');
}
Use Cases
- Remove entire sections of registry data
- Clean up during application uninstall
- Delete obsolete registry keys
- Remove temporary registry sections
- Reset all settings by deleting the key
Notes
- Always operates under
HKEY_CURRENT_USERroot key - WARNING: Deletes the key and ALL its values
- Cannot be undone
- Returns
falseif the key doesn't exist - Use
deleteValue()to delete individual values instead