#151063 - 2005-11-04 05:24 PM
Can not delete a tree registry
|
jaïd
Lurker
Registered: 2005-11-04
Posts: 3
|
Hi,
This is the sample tree: Windows Registry Editor Version 5.00 [HKEY_CURRENT_USER\test] [HKEY_CURRENT_USER\test\NetWare] [HKEY_CURRENT_USER\test\Novell] [HKEY_CURRENT_USER\test\test2] [HKEY_CURRENT_USER\test\test2\Test4] "thepath2"="ccekle" [HKEY_CURRENT_USER\test\Test3] "ThePath"="Bozo" and this is my kix script(sorry for the french comments): ;============================================================================ ; EnumKeys.KIX = ; = ; Pour une clé donnée en paramètre via la valeur Key, = ; Enumère les sous-clé et leurs valeurs. = ;============================================================================ ;BREAK ON
;============================================================================ ; Démarrage du programme = ;============================================================================ IF $Key = 0 $Key = "HKEY_CURRENT_USER\test" CLS ; Clear screen Settitle("EnumKeys.kix, Programme de recherche dans la base de registre.") $StringToFind="test" ENDIF ;============================================================================ ; Premièrement, énumérer les sous-clés. = ;============================================================================ ;déclarations de variables locales ;============================================================================ DIM $Index, $SaveKey
;============================================================================ ;Initialisation de l'index = ;============================================================================ $Index = 0 $SubKey = EnumKey( $Key , $Index ) WHILE @ERROR = 0 $SaveKey = $Key $Key = $Key + "\" + $SubKey
? "-->" + $Key sleep 1 ;======================================================================== ; contrôle si la chaine recherche est contenu dans la sous-clé = ;======================================================================== $x=InStr($SubKey,$StringToFind) IF $x <> 0 $REP='N' ? "La chaîne recherchée " + $StringToFind + " se trouve dans la sous-clé." ? "Voulez-vous la supprimer?(O/N)" GET $REP IF $REP = 'O' ? "je la supprime et passe à la fin du programme sans scruter les sous-valeurs." $y = DelKey($Key) ? "Code retour de DelKey y= "+ $y If $y = 0 ? "Clé supprimée...." Endif ENDIF sleep 1 ENDIF
CALL "\\karma\m-kalkoul\Dev\KixTart\Scripts\FindKeys\Save\EnumKeys.kix" $Key = $SaveKey IF @ERROR = 0 ; try for next subkey $Index = $Index + 1 $SubKey = EnumKey( $Key , $Index ) ENDIF LOOP
;============================================================================ ; Enumération de toute les valeurs de la sous-clés = ;============================================================================ $Index = 0 $Value = EnumValue( $Key , $Index ) WHILE @ERROR = 0 ? $Key + "|" + $Value sleep 1
$Index = $Index + 1 $Value = EnumValue( $Key , $Index ) LOOP
;=========================FIN DU PROGRAMME=================================== :FIN ? "Fin du programme" sleep 2 EXIT 0 = ;============================================================================ results and problems: I'm looking for the "test" string, and when it find [HKEY_CURRENT_USER\test\test2] which has one subkey with a value with deltree function, it sends a return code equal to 5, and I know it's because it has a subkey because for every other subkey which has the string test, it can be deleted. Someone can say me why it doesn't work?
Thanks in advance for your help, Jaïd
|
|
Top
|
|
|
|
#151067 - 2005-11-07 05:31 PM
Re: Can not delete a tree registry
|
jaïd
Lurker
Registered: 2005-11-04
Posts: 3
|
Sorry, in effect, I must use dellkey and it works apparently. But I need some advices about the logical. This a script wich displays subkeys: ;BREAK ON IF $Key = 0 $Key = "HKEY_CURRENT_USER\test" CLS ; Clear screen Settitle("EnumKeys.kix, Programme de recherche dans la base de registre.") $StringToFind="test" ENDIF ;============================================================================ ; enumerates subkeys. = ;============================================================================
DIM $Index, $SaveKey
$Index = 0 $SubKey = EnumKey( $Key , $Index ) WHILE @ERROR = 0 $SaveKey = $Key $Key = $Key + "\" + $SubKey
? $Key ; displaying subkeys sleep 1 CALL "\\karma\m-kalkoul\Dev\KixTart\Scripts\FindKeys\Save\EnumKeys.kix" $Key = $SaveKey IF @ERROR = 0 ; try for next subkey $Index = $Index + 1 $SubKey = EnumKey( $Key , $Index ) ENDIF LOOP
$Index = 0 $Value = EnumValue( $Key , $Index ) WHILE @ERROR = 0 ? $Key + "|" + $Value ;Displaying of values
$Index = $Index + 1 $Value = EnumValue( $Key , $Index ) LOOP
:FIN
EXIT 0 ;============================================================================
I'etsted it and it works fine. But as it's call itself, I couldn't do what I want. The goal is for a given string , deleted all subkeys and values and don't know where I can put the delkey function to having a clean script.
Someone can help me? Thanks in advance, Jaïd.
|
|
Top
|
|
|
|
#151069 - 2005-11-07 09:16 PM
Re: Can not delete a tree registry
|
jaïd
Lurker
Registered: 2005-11-04
Posts: 3
|
sorry,
can explain me what does mean code tags?
Thanks, Jaïd
|
|
Top
|
|
|
|
Moderator: Glenn Barnas, NTDOC, Arend_, Jochen, Radimus, Allen, ShaneEP, Ruud van Velsen, Mart
|
0 registered
and 1471 anonymous users online.
|
|
|