SlimShady Posted July 15, 2004 Posted July 15, 2004 I started making this script after I read this topic.But I don't know how to create an infinite loop that searches recursively.I get confused and my brain hurts when I'm trying to find a solution.Can someone please help.Here's the script: http://www.autoitscript.com/fileman/users/public/SlimShady/SearchReg.au3Thank you.
Davman Posted July 19, 2004 Posted July 19, 2004 I couldnt get autoit to search through the registry... so i exported to a text file and searched through that instead. When i say search, i *literally* mean search. It opens it in wordpad, selects the line, copies to notepad, and checks the variables. If this is the solution you want i can drop the code to you no probs. Sitting comfortably behind the code.
SlimShady Posted July 19, 2004 Author Posted July 19, 2004 No, I mean searching through the registry on-the-fly. First I was stupid and exported HKEY_LOCAL... and HKEY_CURRENT... The files were huge and it took hours to search through the 2 files. That's why I'm using RegEnumKey and RegEnumVal (available in beta version). I'll check my script again and see if I can figure it out now.
Davman Posted July 19, 2004 Posted July 19, 2004 ok, no problems... i don't usually play with beta software, so your on your own there Sitting comfortably behind the code.
Holger Posted July 19, 2004 Posted July 19, 2004 (edited) @SlimShady: I will try it. I have a loop for quering directories (permission-difference-checker) so I try to reconfigure it for registry... Maybe another one has a solution... Edit: forgot something: what should be the result? An array with the found keys, data, etc. or like in regedit the first/next entry? Edited July 19, 2004 by Holger Old project:GUI/Tray menu with icons and colors Other old stuff:IconFileScanner, TriState/ThreeState GUI TreeView, GUI ContextMenu created out of a TreeView
SlimShady Posted July 19, 2004 Author Posted July 19, 2004 (edited) In my script I write every found result to a file. But an array is good, too. Thank you for your help. Edited July 19, 2004 by SlimShady
Holger Posted July 19, 2004 Posted July 19, 2004 (edited) @SlimShady: try this: expandcollapse popupGlobal $regarr[1000][3]; -> maybe put bigger with "redim" in the RegToArr-function ;means [what][subkey][foundin] -> ["key"][subkey][...] or ["value"][subkey][...] or ["valuevalue"][subkey][...] Global $arridx = 0 $searchstring = "SourcePath" RegSearch("HKEY_LOCAL_MACHINE") ;RegSearch("HKEY_USERS") For $idx = 1 To $regarr[0][0] Msgbox(0,"",$regarr[$idx][0] & @LF & $regarr[$idx][1] & @LF & $regarr[$idx][2]) Next $regarr = 0 Exit Func RegSearch($subreg) Local $subreg, $idx, $subidx, $regkey, $regkeyname, $regkeyvalue, $regvalue $idx = 1 While 1 $regkey = RegEnumKey($subreg,$idx) If @error = -1 Or @error = 1 Then ExitLoop If StringInStr($regkey,$searchstring) > 0 Then RegToArr("key",$subreg,$regkey) $regkeyname = $subreg & "\" & $regkey $subidx = 1 While 1 $regkeyvalue = RegEnumVal($regkeyname,$subidx) If @error = -1 Or @error = 1 Then ExitLoop If StringInStr($regkeyvalue,$searchstring) > 0 Then RegToArr("value",$regkeyname,$regkeyvalue) $regvalue = RegRead($regkeyname,$regkeyvalue) ;If $regvalue <> 1 And StringInStr($regvalue,$searchstring) > 0 Then RegToArr("valuevalue",$regkeyname,$regvalue) If $regvalue <> 1 And StringInStr($regvalue,$searchstring) > 0 Then RegToArr("valuevalue",$regkeyname & "\" & $regkeyvalue,$regvalue) $subidx = $subidx + 1 WEnd RegSearch($regkeyname) $idx = $idx + 1 ;Sleep(1); better set to reduce cpu like Regedit does WEnd EndFunc Func RegToArr($string,$key,$value) $arridx = $arridx + 1 If $arridx = (UBound($regarr) - 1) Then Redim $regarr[$arridx + 26][3]; 25 more array-fields $regarr[0][0] = $arridx $regarr[$arridx][0] = $string $regarr[$arridx][1] = $key $regarr[$arridx][2] = $value EndFunc I hope it works so far. But you could test it out and give short feedback if this is what you need... Edit: ok, there is a little but: so maybe it is better to write the $regkeyvalue also to the array... Edited July 19, 2004 by Holger Old project:GUI/Tray menu with icons and colors Other old stuff:IconFileScanner, TriState/ThreeState GUI TreeView, GUI ContextMenu created out of a TreeView
SlimShady Posted July 19, 2004 Author Posted July 19, 2004 I changed ;Sleep(1) to Sleep(5) and ran the script. After a while I got this error and AutoIt closed the script. --------------------------- AutoIt Error --------------------------- Line 43 (File "C:\Documents and Settings\_my_username_\Desktop\RegSearch.au3"): $regarr[$arridx][0] = $string ^ ERROR Error: Array variable has incorrect number of subscripts or subscript dimension range exceeded. --------------------------- OK ---------------------------
Holger Posted July 19, 2004 Posted July 19, 2004 (edited) You have to modify the RegToArr() a little bit cause of more values then the array can save:Func RegToArr($string,$key,$value) $arridx = $arridx + 1 If $arridx = (UBound($regarr) - 1) Then Redim $regarr[$arridx + 26][3]; 25 more array-fields $regarr[0][0] = $arridx $regarr[$arridx][0] = $string $regarr[$arridx][1] = $key $regarr[$arridx][2] = $value EndFuncSo with UBound(array-size)-checking that should no problem anymore Edited July 19, 2004 by Holger Old project:GUI/Tray menu with icons and colors Other old stuff:IconFileScanner, TriState/ThreeState GUI TreeView, GUI ContextMenu created out of a TreeView
SlimShady Posted July 20, 2004 Author Posted July 20, 2004 Nah.. I prefer writing to a textfile on-the-fly. So I added my WriteToFile function instead of RegToArr and it works perfect. Thank you.
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now