Page 1 of 1 1
Topic Options
#151063 - 2005-11-04 05:24 PM Can not delete a tree registry
jaïd Offline
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
#151064 - 2005-11-04 06:12 PM Re: Can not delete a tree registry
maciep Offline
Korg Regular
*****

Registered: 2002-06-14
Posts: 947
Loc: Pittsburgh
Sounds like you're getting Access Denied. Check out the perms on that key
Top
#151065 - 2005-11-05 02:26 PM Re: Can not delete a tree registry
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
Why don't you use DELTREE() to begin with?
_________________________
There are two types of vessels, submarines and targets.

Top
#151066 - 2005-11-05 03:20 PM Re: Can not delete a tree registry
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
Borrowing from the DelKey section of the manual:
Quote:

This call fails if any subkeys exist within the specified subkey.
Use DelTree if you want to delete a subkey that contains subkeys.


_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#151067 - 2005-11-07 05:31 PM Re: Can not delete a tree registry
jaïd Offline
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
#151068 - 2005-11-07 07:48 PM Re: Can not delete a tree registry
Mart Moderator Offline
KiX Supporter
*****

Registered: 2002-03-27
Posts: 4673
Loc: The Netherlands
Please use the code tags in future posts. Posted scripts are much more readable when code tags are used.
_________________________
Mart

- Chuck Norris once sold ebay to ebay on ebay.

Top
#151069 - 2005-11-07 09:16 PM Re: Can not delete a tree registry
jaïd Offline
Lurker

Registered: 2005-11-04
Posts: 3
sorry,

can explain me what does mean code tags?

Thanks, Jaïd

Top
#151070 - 2005-11-07 09:29 PM Re: Can not delete a tree registry
Mart Moderator Offline
KiX Supporter
*****

Registered: 2002-03-27
Posts: 4673
Loc: The Netherlands
Please have a look at this link.
HOWTO: Submit code to / copy code from the board
_________________________
Mart

- Chuck Norris once sold ebay to ebay on ebay.

Top
Page 1 of 1 1


Moderator:  Glenn Barnas, NTDOC, Arend_, Jochen, Radimus, Allen, ShaneEP, Ruud van Velsen, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 1471 anonymous users online.
Newest Members
Viginette, ManuvdWielNL, Sir_Barrington, batdk82, StuTheCoder
17888 Registered Users

Generated in 0.06 seconds in which 0.034 seconds were spent on a total of 11 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org