You can use SHDeleteKey from the shlwapi library:
code:
// Registry key locations
var HKEY_CLASSES_ROOT = 0x80000000;
var HKEY_CURRENT_USER = 0x80000001;
var HKCU = HKEY_CURRENT_USER;
var HKEY_LOCAL_MACHINE = 0x80000002;
var HKEY_USERS = 0x80000003;
/**
* Registry_DeleteTree
* lKeyLocation: One of the HKEY_* constants, such as HKEY_CURRENT_USER
* sKey: Path of the key to delete
*/
function Registry_DeleteTree(lKeyLocation, sKey){
return Interop.Call('shlwapi.dll', 'SHDeleteKeyW', lKeyLocation, sKey) === 0;
}
//EXAMPLE
var RegistryPath = MsgPlus.ScriptRegPath.substr(5); //Remove "HKCU\" prefix
Registry_DeleteTree(HKEY_CURRENT_USER, RegistryPath + "\\KeyToDelete");
For more information about this function, go to the
MSDN page of SHDeleteKey.