Jump to content

Recommended Posts

Posted (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 by ACalcutt

Andrew Calcutt

Http://www.Vistumbler.net

Http://www.TechIdiots.net

Its not an error, its a undocumented feature

Posted

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...
Posted

yes, it apears in plain text and shows all the keys...

ex. the first few lines are

not sure why it wouldn't work like that then, but not sure why you'd need the export file either...
Posted

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

Posted

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

the 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.
Posted

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

Posted (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 by ACalcutt

Andrew Calcutt

Http://www.Vistumbler.net

Http://www.TechIdiots.net

Its not an error, its a undocumented feature

Posted

aww...comeon...why cant people just leave the cat alone :lmao:

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.

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...