Jump to content


This is a ready-only archive of the InstallSite Forum. You cannot post any new content here. / Dies ist ein Archiv des InstallSite Forums. Hier können keine neuen Beiträge veröffentlicht werden.
Photo

How do I delete a HKCU key


4 replies to this topic

Oogle

Oogle
  • Members
  • 11 posts

Posted 22 November 2003 - 00:34

I'd like to delete a registry key in HKCU without having to install anything into it because my app will create HKCU keys on its own.

But everytime I add an entry in the component and registry table, I get an ICE57 error. If I put my HKCU key into its own component, I get both ICE18 and ICE57 errors. How can I fix this??

Edited by Oogle, 22 November 2003 - 00:34.


Petch

Petch
  • Members
  • 35 posts

Posted 24 November 2003 - 14:08

It might be because Windows Installer treats the file as per-system file(maybe you are trying tot run a .reg file). Normally this means that you have both HKCU and HKLM data associated with one component. ICE18 means you have a directory set as keypath and asks you to create the folder using CreateFolder table.

unsure.gif

Robo Scripter

Robo Scripter
  • Members
  • 15 posts

Posted 24 November 2003 - 15:20

The native msi method of deleting Registry keys is the Remove Registry Table and Action.

Please reference the SDK Help for a more complete instruction. But you basicly create an empty component then sight the component in the RemoveRegisrty table.

Another way would be to run a vbscript in run imediate.
Here's a Sample:

'Const HKCU = &H80000001 'HKEY_CURRENT_USER
'Set oReg = GetObject _
' ("winmgmts:{impersonationLevel=impersonate}!\\" _
' & strComputer & "\root\default:StdRegProv")
'DeleteRegistryKey HKCU, "SOFTWARE\Test"

Regards,


Robert W. Haynie
Software Integration Consultant
robert.haynie@HaynieHouse.com
+1 (713) 805-4830
Be the stone that sharpens the leading edge.

Oogle

Oogle
  • Members
  • 11 posts

Posted 24 November 2003 - 15:54

Ok, so I use the RemoveRegistry to remove the key on install...

So, how about removing the key on uninstall? I only have this "remove HKCU key" in my component. Why would I get ICE errors about per-system files when I don't have any files in my component??

Thanks

Robo Scripter

Robo Scripter
  • Members
  • 15 posts

Posted 24 November 2003 - 17:01

OK, I'm going to get a lot of flack for this on but here it goes any way.

I gave up trying to get all of the ICE Rules happy years ago. Microsoft does not seem to try to adhere to them either and they wrote most of them. I figure I’m safe. The important thing that I have found is does the application installation do what you want it to and is it safe to the targeted system.

I rarely use the RemoveRegistry Table and Action as I prefer the extended control that I get via the vbscript.

The RemoveRegisrty Action does not work on Un-Install but the Script does quite well.

Here is the full Script snipit:
Const HKCU = &H80000001 'HKEY_CURRENT_USER
strComputer = "."
Set oReg = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer & "\root\default:StdRegProv")
DeleteRegistryKey HKCU, "SOFTWARE\Test"

Sub DeleteRegistryKey(hive,key)
On Error Resume Next
rc = oReg.EnumKey(hive,key,arSubKeys)
'WScript.Echo key & " a"
For Each sKey In arSubKeys
If Err Then
'WScript.Echo key & " b"
Err.Description
Err.Clear
rc = oReg.DeleteKey(hive,key)'TEST SET
Exit Sub
End If
'WScript.Echo key & " c"
DeleteRegistryKey hive, key & "\" & sKey
Next
'WScript.Echo key & " d"
rc = oReg.DeleteKey(hive,key)
End Sub

This little ditty will delete the targeted key and all subs.

Regards,



Robert W. Haynie
Software Integration Consultant
robert.haynie@HaynieHouse.com
+1 (713) 805-4830
Be the stone that sharpens the leading edge.