#39728 - 2003-05-01 12:58 AM
SReg Problem (Array Out of Bounds)
|
R. Baker
Fresh Scripter
Registered: 2003-01-23
Posts: 7
|
Hello all!
I've used kix for a few scripts, but I'm stuck on an issue. I'm writing (or trying to write) a script to manually uninstall NAV Corp Edition on 95 clients, as there are several client that won't uninstall by conventional means. Symantec has a doco which explains what needs to be done. One of the steps is to search for and delete all instances of 74BE21DBFDBD3D11EBAE000ACC725290 & VirusProtect6.
I've figured out that I need to use SReg to search for particular subkeys. I was able to use SReg to find all instances of 74BE21DBFDBD3D11EBAE000ACC725290 (although I can't use "0" for the integer parameter, but that's another story) However, when I try to search for VirusProtect6, I get and "Array out of bounds" error msg. I gather the problem is with the "6" or its interpation of, but how do I get around it? The expression I've tried is $index=Sreg("HKEY_LOCAL_MACHINE","virusprotect6",2)
Any help greatly appreciated.
Regards,
R. Baker
|
|
Top
|
|
|
|
#39731 - 2003-05-01 12:06 AM
Re: SReg Problem (Array Out of Bounds)
|
R. Baker
Fresh Scripter
Registered: 2003-01-23
Posts: 7
|
Using v 4.20. I tried replacing the string as suggested. I still get the same error "Array reference out of bounds". With this mod, the other reg key search fails as well with an "unknown command [74BE21DBFDBD3D11EBAE000ACC725290]! with 74BE21DBFDBD3D11EBAE000AC highlighted.
The reason why I suspected the problem is with the number is that if I search for virusprotect I get a result. Problem is it finds HKEY_LOCAL_MACHINE\Software\Microsoft\Office\8.0\New User Settings\PowerPoint\Options,MacroVirusProtection and not HKEY_LOCAL_MACHINE\Software\Intel\LanDesk\VirusProtect6!
Why? (and why me??!)
RB
|
|
Top
|
|
|
|
#39735 - 2003-05-02 12:56 AM
Re: SReg Problem (Array Out of Bounds)
|
R. Baker
Fresh Scripter
Registered: 2003-01-23
Posts: 7
|
Script attached as requested. Also tried 2nd mod and still produces the same error.
;Function Sreg() ; ;Author Lonkero ; ;Version 1.0 (15.01.2002 [GMT+2 04:45]) ; ;Action Searches specified string from value and/or valuename in specified ; subkey-tree in registry and returns all occurances in array. ; ;Syntax Sreg(Subkey, String, Integer) ; ;Parameters ; ; Subkey ; Defines from wherein registry to search for. ; Registry pointing rules apply. ; Supports remoteregistry scan. ; ; String ; tells the string to search for. ; ; Integer ; 0 for Valuename ; 1 for Value ; 2 for Both ; ;Remarks ; Nice, pure KiXsolution for regfinds! ; Waiting for multidimensional array support. Until that output not so nice. ; Full search on root keys can take up really much time. ; Test run on just HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft against "id" gave results: ; runtime: 35secons (previous builds approx. 5minutes!) ; found: 1587 matches ; memreserved: after return 112kB, at most 5888kB (previous release 28800kB!) ; ; So for your best, use as lowlevel subkeys as possible. ; Parsed the code to be shorter and lost lots of unneeded lines, but also got it ; really hard to follow the code. Kind of encrypted it ; ; ;Returns ; one dimensional array containing values where string occured. ; array format is SUBKEY,VALUENAME ; ; On error ; nonexistent subkey-input 1010,ERROR_BADKEY ; zero length string-input 24,ERROR_BAD_LENGTH ; Integer input not 0, 1 nor 2 50,ERROR_NOT_SUPPORTED ; ;Dependencies ; none ; ;Example break on ;$index=Sreg("HKEY_LOCAL_MACHINE\Software\Microsoft","id",2) ; as per original and works ;$index=Sreg("HKEY_LOCAL_MACHINE","74be21dbfdbd3d11ebae000acc725290",2) ;works ;$index=Sreg("HKEY_LOCAL_MACHINE","virusprotect6",2) ; doesn't work $index=Sreg("HKEY_LOCAL_MACHINE","virusprotect",2) ; produces result but doesn't find virusprotect6
if @error "error occured: @serror" ? else for each $value in $index ? $value next endif exit 0 ; ;Source 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
|
|
Top
|
|
|
|
#39737 - 2003-05-04 02:46 AM
Re: SReg Problem (Array Out of Bounds)
|
R. Baker
Fresh Scripter
Registered: 2003-01-23
Posts: 7
|
I had a quick look at that new funcion before I left work on Friday. Looks like it's going to work. Thanks for your help.
R. Baker
|
|
Top
|
|
|
|
Moderator: Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart
|
0 registered
and 2220 anonymous users online.
|
|
|