Page 1 of 1 1
Topic Options
#72039 - 2002-12-05 06:56 PM re: Sreg() - Searches registry for specified value and/or valuename
Shawn Administrator Offline
Administrator
*****

Registered: 1999-08-13
Posts: 8611
Jooel - just had to mention this and give you much thanks and credit - this function of yours just saved our bacon. One of my co-workers has used it to setup a batch job that scours the registry (a portion of it) for a rogue value that gets created now and again (and must be deleted) ... works and charm and saved us much time and effort.

-Shawn

Top
#72040 - 2002-12-05 07:03 PM Re: re: Sreg() - Searches registry for specified value and/or valuename
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11631
Loc: CA
Shawn,

Where is the link to Sreg() that you are referring to?

If it is random, why does it have to be deleted? Do you have any further details as to why/what the value deal is and what problem it is causing?

Top
#72041 - 2002-12-05 07:09 PM Re: re: Sreg() - Searches registry for specified value and/or valuename
Shawn Administrator Offline
Administrator
*****

Registered: 1999-08-13
Posts: 8611
emmm - heres the link to the UDF:

Sreg() - Searches registry for specified value and/or valuename

All I know is my buddy runs up to me with this urgent requirement to scour the registry for a particular data value actually - not a key or value - that can appear in numerous places under a certain tree node.

Not too certain on all the details but it has something to do with a "random" print driver being installed by some product - and must be deleted to get things working again ... apparently this is a stop-gap fix until MS comes back with a reponse or fix. Not only does the registry need cleaning, but the disk file has to be purged as well. This is on a server (I think)

-Shawn

Top
#72042 - 2002-12-05 07:56 PM Re: re: Sreg() - Searches registry for specified value and/or valuename
Shawn Administrator Offline
Administrator
*****

Registered: 1999-08-13
Posts: 8611
Little bit more info - while W2K server is (ehhh) serving ... some product slips a rouge print driver into the system. When server reboots, it would hang on startup screen. Stop-gap to have deamon running to search for suspect key/value & files every 5-10 minutes, and purge them from the system. Thats all I know at this point.

[ 05. December 2002, 19:56: Message edited by: Shawn ]

Top
#72043 - 2002-12-05 09:45 PM Re: re: Sreg() - Searches registry for specified value and/or valuename
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
shawn, this is good info that it helped.
tryid it about month ago on me own laptop against hkcu-hive and stopped it after 50minutes [Wink]

but for specific subkeys I've found it helpfull too.
_________________________
!

download KiXnet

Top
#72044 - 2002-12-05 11:54 PM Re: re: Sreg() - Searches registry for specified value and/or valuename
Shawn Administrator Offline
Administrator
*****

Registered: 1999-08-13
Posts: 8611
Yeah - im starting the search from about four or five keys up the chain - plenty fast but more importantly than speed - it had to be accurate (and not miss any nodes) - which it is.
Top
#72045 - 2002-12-06 06:53 PM Re: re: Sreg() - Searches registry for specified value and/or valuename
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
mmm...
should do something about it.
made it when there was just 4 rc...

it has no dimming and split joins could also speed it up.

also, total dump and reading from there could be faster than quering the registry value by value...

but sure, that is the UDF which I needed to work the longest time.

many nights just coding to get the executions work and not interfier with each other...
_________________________
!

download KiXnet

Top
#72046 - 2002-12-06 07:11 PM Re: re: Sreg() - Searches registry for specified value and/or valuename
Shawn Administrator Offline
Administrator
*****

Registered: 1999-08-13
Posts: 8611
Thats the beauty of it Jooel - i don't know (don't have to know) how you implemented it - just that its self-contained, doesn't interfere with the rest of my script, and it works. The only thing I had to deal with is the interface - which you documented nicely right up front.

[ 06. December 2002, 19:11: Message edited by: Shawn ]

Top
#72047 - 2002-12-06 07:35 PM Re: re: Sreg() - Searches registry for specified value and/or valuename
Crazy Eddie Offline
Starting to like KiXtart

Registered: 2002-11-20
Posts: 105
Loc: Sacramento, CA USA
Lonkero

Have you considered using the REGEDIT built-in functions as an external command to improve performance?

(It would not be PURE kix, but reather KIX, with a command prompt, and temp files.)

code:
REGEDIT /E filename1 [regpath1]
/E filename1 Specifies the file to export the registry to.
Regpath1 Specifies the starting registry key to export from. (Defaults to exporting the entire registry).

I've seen some fancy VBS scripts using this feature.

-Ed
_________________________
{Insert your favorite Witty Tag Line here}

Top
#72048 - 2002-12-06 07:43 PM Re: re: Sreg() - Searches registry for specified value and/or valuename
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
we think using files is not pure kix.

I thought it at some point but then could have used some other external things too.

I rather spend some time more than use enternal files.

I know some things already what can improve performance but that UDF is so complicated that I rather start a new one than start modifying it.
_________________________
!

download KiXnet

Top
#72049 - 2002-12-06 07:54 PM Re: re: Sreg() - Searches registry for specified value and/or valuename
Crazy Eddie Offline
Starting to like KiXtart

Registered: 2002-11-20
Posts: 105
Loc: Sacramento, CA USA
I understand.

REGEDIT is a part of the OS...so it doesn't hurt my sense of "fair play" to consider it pure KIX.

On another note...VBS has a VERY nice feature that I wish KIX had natively...

quote:
WshScriptExec
Provides status information about a script run with Exec along with access to the StdIn, StdOut, and StdErr streams.

Remarks
The WshScriptExec object is returned by the Exec method of the WshShell object. The Exec method returns the WshScriptExec object either once the script or program has finished executing, or before the script or program begins executing.

This would be really, really useful.
_________________________
{Insert your favorite Witty Tag Line here}

Top
#72050 - 2002-12-06 07:58 PM Re: re: Sreg() - Searches registry for specified value and/or valuename
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
I think that equivalent of the wsh-shell has been asked for multiple times.

I'd want a shell that runs as hidden and controls the flow...
spawning (or whatever it's called)
_________________________
!

download KiXnet

Top
#72051 - 2002-12-06 08:02 PM Re: re: Sreg() - Searches registry for specified value and/or valuename
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
jens?
_________________________
!

download KiXnet

Top
#72052 - 2002-12-07 07:23 PM Re: re: Sreg() - Searches registry for specified value and/or valuename
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
Brainfart [Wink] Posted utter garbage, thus deleted post again.
_________________________
There are two types of vessels, submarines and targets.

Top
#72053 - 2003-01-06 07:47 PM Re: re: Sreg() - Searches registry for specified value and/or valuename
ShaneEP Moderator Offline
MM club member
*****

Registered: 2002-11-29
Posts: 2127
Loc: Tulsa, OK
Hello everybody...

I am trying to implement your Sreg function to search the
HKEY_CURRENT_USER\Printers\Connections
keys for any printers on a particular server. Here is the code I am trying...I dont get anything back when I run it but I know that there are
keys in the tree that have the servername in the value. Im sure that its just my Kix ignorance thats the problem...Any assistance would be
greatly appreciated.

code:
 
break on

$index=Sreg("HKEY_CURRENT_USER\Printers\Connections","servername",1)
if @error
"error occured: @serror" ?
else
for each $value in $index
? $value
next
endif
exit 0

Function Sreg($_Subkey, $_String, $_Integer)
if not keyexist("$_Subkey") exit 1010 endif
if not len($_String) exit 24 endif
if $_Integer<0 or $_Integer>2 exit 50 endif
$_I="" $_Chr=chr(29)
$=execute('sk("$_Subkey","$_String",$_Integer)')
$_C=0 $_Is =""
for each $_F in split($_I,$_Chr) if len($_F) $_C=$_C+1 endif next
$_C=$_C-1
$=execute('global $$_IA[$_C]')
$_C=0
for each $_F in split($_I,$_Chr) if len($_F) $=execute('$$_IA[$_C]="$_F"') $_C=$_C+1 endif next
$Sreg=$_IA
$_I="" $_IA=""
EndFunction
Function sk($_key, $_St, $_In)
$_vC=0
$_Vn=enumvalue($_key,$_vC)
while len($_Vn)
if $_In=0
if instr($_Vn,$_St) $_I=$_I+$_key+",$_Vn"+$_Chr endif
else
if instr(readvalue($_key,$_Vn),$_St) $_I=$_I+$_key+",$_Vn"+$_Chr else if $_In=2 and instr($_Vn,$_St) $_I=$_I+$_key+",$_Vn"+$_Chr endif endif
endif
$_vC=$_vC+1
$_Vn=enumvalue($_key,$_vC)
loop
$_C=0 $_ID=""
$_Un=enumkey($_key,$_C)
while len($_Un)
$_ID=$_ID+"$_key\$_Un,"
$_C=$_C+1
$_Un=enumkey($_key,$_C)
loop
for each $_uk in split($_ID,",") if len($_uk) $=execute('sk("$_uk","$_St",$_In)') endif next
EndFunction



[ 06. January 2003, 19:48: Message edited by: Shane Ptomey ]

Top
#72054 - 2003-01-06 07:49 PM Re: re: Sreg() - Searches registry for specified value and/or valuename
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
Take a look at the ArrayEnumKey() and ArrayEnumValue() UDFs. They might solve the issue more elegantly.
_________________________
There are two types of vessels, submarines and targets.

Top
#72055 - 2003-01-06 08:12 PM Re: re: Sreg() - Searches registry for specified value and/or valuename
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
can't say much what is wrong as on homenetwork and there is no printers connected here.

anyway, as this is matter of place you know for sure, using enumkey indeed is one really good way to do this.
_________________________
!

download KiXnet

Top
#72056 - 2003-01-06 08:33 PM Re: re: Sreg() - Searches registry for specified value and/or valuename
ShaneEP Moderator Offline
MM club member
*****

Registered: 2002-11-29
Posts: 2127
Loc: Tulsa, OK
Got it work using the EnumKey with the following code...Thanks for all the great functions guys!

code:
break on
$oldserver = "ServerName"

$array=arrayenumkey(HKEY_CURRENT_USER\Printers\Connections)
for $counter=0 to ubound($array)
$key = $array[$counter]
IF INSTR ("$key", "$oldserver")
DELKEY ("HKEY_CURRENT_USER\Printers\Connections\$key")
? 'Deleting $key'
ENDIF
next

get $
exit 0

function arrayenumkey($regsubkey)
dim $retcode, $subkeycounter, $currentsubkey, $subkeyarray

if not keyexist($regsubkey)
$arrayenumkey=''
return
endif

$subkeycounter=0
do
$currentsubkey=enumkey($regsubkey,$subkeycounter)
if $currentsubkey<>259 and @ERROR=0
redim preserve $subkeyarray[$subkeycounter]
$subkeyarray[$subkeycounter]=$currentsubkey
$subkeycounter=$subkeycounter+1
endif
until $currentsubkey=259 or @ERROR

$arrayenumkey=$subkeyarray
endfunction


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 484 anonymous users online.
Newest Members
Sir_Barrington, batdk82, StuTheCoder, M_Moore, BeeEm
17886 Registered Users

Generated in 0.068 seconds in which 0.024 seconds were spent on a total of 12 queries. Zlib compression enabled.

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