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

Removing registry key from all users HKCU


6 replies to this topic

healla

healla
  • Members
  • 3 posts

Posted 18 June 2002 - 20:47

I have a registry key in HKCU which gets created as different users use my product. When I uninstall my product, I need to remove all the traces of this key i.e. I need to remove this key from HKCU of all the users that have used my product.

One way I can think of is to write a custom action that would go to all the hives in HKU and delete this registry key if present. Is there any other standard way to do this?

Thanks
healla

mgrove

mgrove
  • Members
  • 14 posts

Posted 19 June 2002 - 20:32

Unfortunatly, option one does not nessisarally work.  If your software is installed in a user environment where the profiles are kept up on the server (roaming profiles) then (from what I understand) when the user logs in, any changes made to HKEY_USERS are replaced with the server copy (and all your keys reappear).

I would be interested in seeing if there is any better solutions for this problem...

aseyer

aseyer
  • Members
  • 21 posts

Posted 20 June 2002 - 19:16

The only way I have been able to get around this problem is when the uninstall is run, use a custom action to install a small executable somewhere on the users machine which, when ran, deletes the keys from HKCU.  You would then place a registry key in the HKLM\Software\MicroSoft\Windows\CurrentVersion\Run to execute the program every time a user logs in.

Of course, from then on, EVERY time a user logged into the machine, the keys would attempt to be deleted, slowing down log in times by whatever time it took the executable to run.  You install would also have to know to delete the file if present on INSTALL, so a repair wouldn't possibly be triggered every time the app was launch post login.

A horrible solution, but the only one I have been able to use for when you absolutly, positively can't leave a registry key behind in HKCU.

PhilWilson

PhilWilson
  • Members
  • 10 posts

Posted 21 June 2002 - 21:04

I think you could do this if your app added a program to the HKCU\.....\Run key. It would run every time that user logged on. If your app is still installed it does nothing. If your app is NOT still installed, it deletes the HKCU registry keys and then deletes its own ..\Run key and sets up a remove of itself after the next reboot.

hambone

hambone
  • Members
  • 206 posts

Posted 15 July 2002 - 13:08

over the last few years i have done something similiar here to allow options to be loaded/unloaded from the HKCU registry hive.  i have found that not all settings are stored in the HKU hive.  some is stored off-line in the NTUser.??? files.  if profiles are stored locally then it will be the different NTUser.DAT files in the various user profiles directory.  for roaming profiles and other it is the NTUser.MAN and other files.

sticking with the use of locally stored profiles it is possible to set-up 'run once' commands to process each user registry hive as the user logs in and then perform a self-removal of the run-once code when finished.

i have found that although this mehtod works you are adding processing time to the user log-in cycle and developing management code to support the solution.  another method that i have found to work well is to process all of the user registry hives at the time of the product removal request.

to accomplish this i load each user hive, remove ( add/edit ) the required registry key(s), then save the modified hive back...

to do this programmatically, illustrating this in .BAT/.CMD code, gives us something like this:

1) add the required settings to a .REG file like the following:
REGEDIT4

; to delete a registry key
[-HKEY_LOCAL_MACHINE\NTUser_Hive\SOFTWARE\COREL]

; to add a registry key
[HKEY_LOCAL_MACHINE\NTUser_Hive\SOFTWARE\CORELSuite]


2) process each of the files
:Parse_HKCUReg
rem
rem Build up a list of the .DAT ( HKCU Hives ) for removal of the specific COREL registry keys
   CD Process_NTUserDATs
   echo     *********************************************************************    >> C:\Temp\COREL-Removal.TXT
   CALL Build_HKCU_DAT_List.BAT
rem For each of the local profiles delete any left over run-once programmes
   START "Removing HKCU Info. From User Hives..." /separate /high /min /wait cmd /c FOR /F "delims==" %%i IN (C:\Temp\HKCU_DAT_File_List.TXT) DO Load_Reg_with_HKCU "%%i"
   CD ..
   IF EXIST "C:\Temp\HKCU_DAT_File_List.TXT" DEL /Q "C:\Temp\HKCU_DAT_File_List.TXT" >> C:\Temp\COREL-Removal.TXT
   echo     *********************************************************************    >> C:\Temp\COREL-Removal.TXT
rem
   :END
rem
rem eof Remove-HKCU_COREL.BAT



the following file is used to do the actual HK processing

@echo off
rem
rem  This BATch file loads the different NTUser.DAT files into the registry,
rem in the HKLM\NTUser_Hive key and then proceeds to remove the CORELSuite
rem HKCU registry entries from them.
rem
   echo        Processing user profile: %1                                        >> C:\Temp\COREL-Removal.TXT
   REG LOAD %1 NTUser_Hive  > NUL 2> NUL
   C:\WinNT\RegEdit /S Remove-HKCU_CORELSuite.REG
   REG UNLOAD NTUser_Hive  > NUL 2> NUL
rem
rem eof Load_Reg_with_HKCU.BAT

as i said this method can be written in whatever you wish and allows for all processing to be performed before the user is logged in...

hteichert

hteichert
  • Members
  • 158 posts

Posted 15 July 2002 - 13:22

Hello hambone!

Seems to be a good idea.
But you're calling a batch named "Build_HKCU_DAT_List.BAT
" which builds the "HKCU_DAT_File_List.TXT" and didn't show it's code.

Could you please post this batch, too? Thanks in advance!
h.teichert-ott

hambone

hambone
  • Members
  • 206 posts

Posted 15 July 2002 - 13:32

sorry,  the code to build the list of locally stored NTUser.DAT files is:

DIR C:\WinNT\Profiles\NTUser.DAT /s /b > C:\Temp\HKCU_DAT_File_List.TXT

once again any language could be used...