Sign in to follow this  
Followers 0
Olish

Explore and retrieve Registry in a file

9 posts in this topic

#1 ·  Posted (edited)

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

Share this post


Link to post
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:

Share this post


Link to post
Share on other sites

In fact, there is a problem when the script goes up in the parent subkey, an element of $pIns is deleted but, no element of $pTab is deleted. I'm searching for correcting this...


Olivier, from France.Free Wake On LAN script

Share this post


Link to post
Share on other sites
REGEDIT /e filename.reg HKEY_LOCAL_MACHINE wont work?

Share this post


Link to post
Share on other sites

My aim is to scan registry before an installation, and after, to compare the differences. But reading a .REG file is difficult using INI functions...


Olivier, from France.Free Wake On LAN script

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

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

Share this post


Link to post
Share on other sites

So .reg files are hard to read? Not last time I checked... Just export it like Confuzzled said.

Share this post


Link to post
Share on other sites

So .reg files are hard to read? Not last time I checked... Just export it like Confuzzled said.

It's not so difficult, but reading very long hexadecimal values writen on few lines is not possible with IniRead function.


Olivier, from France.Free Wake On LAN script

Share this post


Link to post
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 *

Share this post


Link to post
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
Sign in to follow this  
Followers 0