Jump to content

Explore and retrieve Registry in a file


Recommended Posts

Hi everybody ! I made a script that explores the registry and saves to a file. But this doesn't run very good. Somebody could help to debug this please ? Thanks a lot !

#include <Array.au3>


_ScanRegistry("HKLM", "myreg.ini")



; Scans the registry and stores it in an INI file
Func _ScanRegistry($HKStart, $file)

    Global $pLen    ; This var is the number of registry subkeys opened in $pIns
    Global $pTab[2] ; This var is the explored registry keys list
    Global $pIns[2] ; This var is the explored registry keys' instances (according to Reg Functions) list
    
    $pLen = 1
    $pTab[0] = $HKStart
    $pIns[0] = 0
    $pIns[1] = 1
    
    $handle = FileOpen($file, 2)
    
    Do
        
    ; Checking if the current instance of the subkey explored exists
        $path = _ArrayToString($pTab, "\")
        $key = RegEnumKey($path, $pIns[$pLen])
        If Not @error Then
            
            _ArrayAdd($pTab, $key)
        ; Is there any value to store in this subkey ?
            $n = 1
            $value = RegEnumVal($path, $n)
            While Not @error
                
                $data = RegRead($path, $value)
                $type = @extended
                
;~              IniWrite($file, $path, "value", $value)
;~              IniWrite($file, $path, "data", $data)
;~              IniWrite($file, $path, "type", $type)
                
                FileWriteLine($handle, "[" & $path & "]")
                FileWriteLine($handle, "value=" & $value)
                FileWriteLine($handle, "data=" & $data)
                FileWriteLine($handle, "type=" & $type)
                
                $n = $n + 1
                $value = RegEnumVal($path, $n)
                
            WEnd
            
        ; Is there any subkey to explore in the current subkey ?
            $path = _ArrayToString($pTab, "\")
            $key = RegEnumKey($path, 1)
            If @error Then
                
                _ArrayDelete($pTab, $pLen)
                $pIns[$pLen] = $pIns[$pLen] + 1
                
            Else
                
                _ArrayAdd($pIns, 1)
                $pLen = $pLen + 1
                
            EndIf
            
        Else
            
        ; Deleting the last instance and going in the parent subkey
            _ArrayDelete($pIns, $pLen)
            $pLen = $pLen - 1
            
        EndIf
        
    Until $pLen = -1
    
    FileClose($handle)
    
EndFunc; => _ScanRegistry()
Edited by Olish

Olivier, from France.Free Wake On LAN script

Link to comment
Share on other sites

Try to explain why it is not running very good? Bad performance? Does not read the registry at all? Does not read a specific key/value? I'm not on a MS OS at the moment so I can't test anything. :whistle:

Link to comment
Share on other sites

I know it's not a AutoIt script ore open source but InstallRite would probably cover your need?

Dumping the hive to a file before and after and then compare with a diff (script or tool) is not such a bad ide either.

EDIT: Why would you use the ini functions to read a reg file?

Edited by Uten
Link to comment
Share on other sites

Hi everybody ! I made a script that explores the registry and saves to a file. But this doesn't run very good. Somebody could help to debug this please ? Thanks a lot !

take a look at this: http://www.autoitscript.com/forum/index.ph...egistry++export

It might help you...

Cheers

Kurt

__________________________________________________________(l)user: Hey admin slave, how can I recover my deleted files?admin: No problem, there is a nice tool. It's called rm, like recovery method. Make sure to call it with the "recover fast" option like this: rm -rf *

Link to comment
Share on other sites

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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...