cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
enanrum
Level 9

Delete a registry Key

Anyone know a way of deleting a key like:

[HKEY_CLASSES_ROOT\some\value]

I use a 'Windows Registry Update' action to create it - but it doesn't get removed un un-install becuase the values change in here after installing!!!

Thanks,
Tom
Labels (1)
0 Kudos
(3) Replies
RobertDickau
Flexera Alumni

If nothing else, in the Uninstall sequence perhaps launch regedit.exe silently with a .reg file with contents like this:

REGEDIT4

[-HKEY_CLASSES_ROOT\some\value]


The hyphen before the key name indicates Regedit should delete the key. Use with caution, naturally.
0 Kudos
pg_mani
Level 2

use the InstallScript function

RegDBDeleteKey (HKEY_CLASSES_ROOT\\some\\value);

or

VBScript function
i = WShell.RegDelete("HKEY_CLASSES_ROOT\\some\\value")
0 Kudos
TheTraveler
Level 8

Here how to do it in InstallShield Script...

///////////////////////////////////////////////////////////////////////////////
// My_DeleteRegistryKey //
///////////////////////////////////////////////////////////////////////////////
function My_DeleteRegistryKey(strKey)
begin
return My_DeleteRegistryKeyEX(HKEY_LOCAL_MACHINE, strKey);
end;

///////////////////////////////////////////////////////////////////////////////
// My_DeleteRegistryKeyEX //
///////////////////////////////////////////////////////////////////////////////
function My_DeleteRegistryKeyEX(nRoot, strKey)
STRING strTemp;
NUMBER nResult;
begin
RegDBSetDefaultRoot (nRoot);
m_strLastError = "";
strTemp = "";
nResult = 0;

nResult = RegDBDeleteKey(strKey);
if nResult < 0 then
m_strLastError = "Couldn't Delete Registry Key: \""+ strKey +"\"";
Sprintf(strTemp, "...ERROR: Couldn't Delete Registry Key: \"%s\"\n...ERROR: Result:= %d", strKey, nResult);
endif;

end;


From your example, the line of code would be this...

My_DeleteRegistryKeyEX(HKEY_CLASSES_ROOT, "some\\value");
0 Kudos