ACalcutt Posted January 23, 2006 Share Posted January 23, 2006 (edited) i am trying to put a expoted reg file(in txt form) into an array, i tried this #include <file.au3> #Include <process.au3> Dim $file = "c:\reg.txt" Dim $array1 Dim $line = 1 _RunDOS('regedit /e "' & $file & '"') _FileReadToArray($file, $array1) MsgBox(0, @error, $array1[1]) For $loop = 0 to $array1[0] msgbox(0, $array1[0], $array1[$line]) If StringInStr($array1[$line], "[") Then MsgBox(0, "1", $array1[$line]) Else $line += 1 EndIf Next this results in $array1[0] = 1 and $array1[1] = some random characters(when it should be "Windows Registry Editor Version 5.00") Edited January 23, 2006 by ACalcutt Andrew Calcutt Http://www.Vistumbler.net Http://www.TechIdiots.net Its not an error, its a undocumented feature Link to comment Share on other sites More sharing options...
seandisanti Posted January 23, 2006 Share Posted January 23, 2006 i am trying to put a expoted reg file(in txt form) into an array, i tried this #include <file.au3> #Include <process.au3> Dim $file = "c:\reg.txt" Dim $array1 Dim $line = 1 _RunDOS('regedit /e "' & $file & '"') _FileReadToArray($file, $array1) MsgBox(0, @error, $array1[1]) For $loop = 0 to $array1[0] msgbox(0, $array1[0], $array1[$line]) If StringInStr($array1[$line], "[") Then MsgBox(0, "1", $array1[$line]) Else $line += 1 EndIf Next this results in $array1[0] = 1 and $array1[1] = some random characters(when it should be "Windows Registry Editor Version 5.00")why not just create the array reading the registry directly? with RegEnumKey() and RegEnumVal() it should be pretty quick work, without the need for the export... Link to comment Share on other sites More sharing options...
ACalcutt Posted January 23, 2006 Author Share Posted January 23, 2006 i was thinking about doing that, but any idea why that wouldn't work? maybe is it to long of a file? Andrew Calcutt Http://www.Vistumbler.net Http://www.TechIdiots.net Its not an error, its a undocumented feature Link to comment Share on other sites More sharing options...
seandisanti Posted January 23, 2006 Share Posted January 23, 2006 i was thinking about doing that, but any idea why that wouldn't work? maybe is it to long of a file?doubtful. have you looked at the exported file? Link to comment Share on other sites More sharing options...
ACalcutt Posted January 23, 2006 Author Share Posted January 23, 2006 (edited) yes, it apears in plain text and shows all the keys... ex. the first few lines are Windows Registry Editor Version 5.00 [HKEY_LOCAL_MACHINE]"InstallPath"="C:\\WINDOWS\\System32\\spool\\DRIVERS\\W32X86\\3" Edited January 23, 2006 by ACalcutt Andrew Calcutt Http://www.Vistumbler.net Http://www.TechIdiots.net Its not an error, its a undocumented feature Link to comment Share on other sites More sharing options...
seandisanti Posted January 23, 2006 Share Posted January 23, 2006 yes, it apears in plain text and shows all the keys...ex. the first few lines arenot sure why it wouldn't work like that then, but not sure why you'd need the export file either... Link to comment Share on other sites More sharing options...
ACalcutt Posted January 24, 2006 Author Share Posted January 24, 2006 I tried this #include <Array.au3> Dim $reg1[1] _RegSubkeys("HKLM", $reg1) $reg1[0] = UBound($reg1) - 1 _ArrayDisplay($reg1, "") Func _RegSubkeys($startkey, ByRef $array) $line=1 While 1 $reg = RegEnumKey($startkey, $line) If @error = -1 Then ExitLoop _ArrayAdd($array, $reg) _RegSubkeys($startkey & "\" & $reg, $array) $line += 1 WEnd EndFunc but i get the error Line 13 _ArrayAdd($array, $reg) Error: Recursion level has been exceeded - AutoIt will quit to preven stack overflow. Andrew Calcutt Http://www.Vistumbler.net Http://www.TechIdiots.net Its not an error, its a undocumented feature Link to comment Share on other sites More sharing options...
seandisanti Posted January 24, 2006 Share Posted January 24, 2006 I tried this #include <Array.au3> Dim $reg1[1] _RegSubkeys("HKLM", $reg1) $reg1[0] = UBound($reg1) - 1 _ArrayDisplay($reg1, "") Func _RegSubkeys($startkey, ByRef $array) $line=1 While 1 $reg = RegEnumKey($startkey, $line) If @error = -1 Then ExitLoop _ArrayAdd($array, $reg) _RegSubkeys($startkey & "\" & $reg, $array) $line += 1 WEnd EndFunc but i get the errorthe error means that your recursion depth exceeded the preset limit of 384. I highly doubt that any one tree of your registry extends 400 levels deep, so that means there is definitely a logic error with your alogrithm. i'm not spotting it just looking at your code, but i can try to whip up a solution for you. I only have half an hour or so left here at work, so it may have to wait until i get home. It may be worth your time in the interim to search scripts and scraps for the terms +recursive +registry as i'm sure someone has already skinned this cat. Link to comment Share on other sites More sharing options...
ACalcutt Posted January 24, 2006 Author Share Posted January 24, 2006 if i replace _addarray with a msgbox it seems to work correctly ... hmmm Andrew Calcutt Http://www.Vistumbler.net Http://www.TechIdiots.net Its not an error, its a undocumented feature Link to comment Share on other sites More sharing options...
GaryFrost Posted January 24, 2006 Share Posted January 24, 2006 just change If @error = -1 Then ExitLoop to If @error Then ExitLoop SciTE for AutoItDirections for Submitting Standard UDFs  Don't argue with an idiot; people watching may not be able to tell the difference.  Link to comment Share on other sites More sharing options...
ACalcutt Posted January 24, 2006 Author Share Posted January 24, 2006 i changed it so i could see what was going on and i found the problem, it was hitting the security key and that didn't have any sub keys , then it just kept putting "\"s ....so i fixed the exit loop If @error = -1 Then ExitLoop became If @error = -1 Or @error = 1 Then ExitLoop #include <Array.au3> #include <GuiConstants.au3> Dim $reg1[10000] Dim $count = 0 GuiCreate("", 392, 120) $edit1 = GuiCtrlCreateEdit("", 10, 30, 370, 80, $WS_VSCROLL) $count1 = GuiCtrlCreateLabel("", 10, 10, 90, 20) GuiSetState() _RegSubkeys("HKLM", $reg1) $reg1[0] = UBound($reg1) - 1 _ArrayDisplay($reg1, "") Func _RegSubkeys($startkey, ByRef $array) $line=0 While 1 $line += 1 $reg = RegEnumKey($startkey, $line) If @error = -1 Or @error = 1 Then ExitLoop $count += 1 GUICtrlSetData ( $edit1, $startkey & "\" & $reg) GUICtrlSetData ( $count1, $count) Sleep(100) _RegSubkeys($startkey & "\" & $reg, $array) WEnd EndFunc Func _RegSubkeys2($startkey, ByRef $array) EndFunc Andrew Calcutt Http://www.Vistumbler.net Http://www.TechIdiots.net Its not an error, its a undocumented feature Link to comment Share on other sites More sharing options...
ACalcutt Posted January 24, 2006 Author Share Posted January 24, 2006 (edited) just changeIf @error = -1 Then ExitLoopto If @error Then ExitLooplol, good call...after i figued out why, but you way is better anyway Edited January 24, 2006 by ACalcutt Andrew Calcutt Http://www.Vistumbler.net Http://www.TechIdiots.net Its not an error, its a undocumented feature Link to comment Share on other sites More sharing options...
ACalcutt Posted January 24, 2006 Author Share Posted January 24, 2006 (edited) this seems to work like it should :-) #include <Array.au3> Dim $reg1[1] _RegSubKeysSubVals("HKLM\SOFTWARE\AutoIt v3", $reg1) $reg1[0] = UBound($reg1) - 1 _ArrayDisplay($reg1, $reg1[0]) Func _RegSubKeysSubVals($startkey, ByRef $array) $line=0 While 1 $line += 1 $reg = RegEnumVal($startkey, $line) If @error Then ExitLoop $data = RegRead($startkey, $reg) _ArrayAdd($array, $reg & "=" & $data) WEnd $line=0 While 1 $line += 1 $reg = RegEnumKey($startkey, $line) If @error Then ExitLoop _ArrayAdd($array, "[" & $startkey & "\" & $reg & "]") _RegSubkeys($startkey & "\" & $reg, $array) WEnd EndFunc Edited January 24, 2006 by ACalcutt Andrew Calcutt Http://www.Vistumbler.net Http://www.TechIdiots.net Its not an error, its a undocumented feature Link to comment Share on other sites More sharing options...
ACalcutt Posted January 24, 2006 Author Share Posted January 24, 2006 (edited) i'm sure someone has already skinned this cat.aww...comeon...why cant people just leave the cat alone Edited January 24, 2006 by ACalcutt Andrew Calcutt Http://www.Vistumbler.net Http://www.TechIdiots.net Its not an error, its a undocumented feature Link to comment Share on other sites More sharing options...
seandisanti Posted January 24, 2006 Share Posted January 24, 2006 aww...comeon...why cant people just leave the cat alone well we're always talking about skinning cats or inventing wheels, and cats and wheels don't mix, so i just stick w/ cats. P**** has never done me wrong. Link to comment Share on other sites More sharing options...
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