Jump to content

Convert Registry File to Autoit Format (RegToAu3)


hunt
 Share

Recommended Posts

This script converts registry file (xp format) to Autoitscript file.

It is useful after reinstallation windows.

For search of the necessary values in registry it is useful to use RegShot.

Time of proccessing for 54mb registry-file on AMD Sempron 3000+ is 41 secs.

How to work with script:

1. Run script

2. Choose files of the register.

3. Wait while a script icon will disappear from the taskbar.

In the end the generated text will be stored in the clipboard.

Features:

1. It is possible to choose some files of the register in Open File Dialog.

2. The indicator (Tooltip) of progress during processing of the big files

Possible problem after processing of files (rare case):

Some text-editors can't to display text after simbols ascii(1-32).

;#NoTrayIcon
$full_text=""
$summ_time=""
$crlf=@crlf
$DesktopWidth=@DesktopWidth
$DesktopHeight=@DesktopHeight
If $CmdLine[0] > 0 Then
    $begin=TimerInit()
    For $i=1 to $CmdLine[0]
        If FileExists($CmdLine[$i]) Then $full_text&=Generating($CmdLine[$i])
    Next
    Clipput($full_text)
Else
    While 1
        $file = FileOpenDialog("Choose File of registry", "", "Registry Files (*.reg)",7)
        If @error Then Exit
        If $file <> "" Then ExitLoop
    WEnd
    $begin=TimerInit()

    $arr_files=StringSplit($file,"|",1)
    If $arr_files[0]>1 Then
        For $i=2 to $arr_files[0]
            $full_text&=Generating($arr_files[1] & "\" & $arr_files[$i])
        Next
    Else
        $full_text=Generating($file)
    EndIf
    
    ClipPut($full_text)
EndIf
;MsgBox(0,"",TimerDiff($begin))
;MsgBox(0,"",$summ_time)

Func Generating($file)
    $arr_reg = StringSplit(FileRead($file), $crlf, 1)
    $text = ""
    $filename=StringRegExpReplace($file,".+\\","")
    If StringInStr($arr_reg[1], "Windows Registry Editor Version") = 0 Then
        MsgBox(16, "Error","File: " & $filename & $crlf & "This type not supported!")
        Exit
    EndIf
    $timer=TimerInit()
    For $i = 2 To $arr_reg[0]
        $t_reg_path = StringRegExp($arr_reg[$i], "\A\h*\[(.+)\]\h*\Z", 1)
        If Not @error Then
            $reg_path = StringReplace($t_reg_path[0], '"', '""')
            ContinueLoop
        EndIf
        $value = StringRegExp($arr_reg[$i], '\h*"(.+?)"\h*=\h*(.+)\h*', 3)
        If @error Then
            $value = StringRegExp($arr_reg[$i], '\h*(@)\h*=\h*(.+)\h*', 3)
            If @error Then ContinueLoop
            $value[0]=""
        Endif

        $value[0] = StringReplace($value[0], '\"', '""')
        $value[1] = StringRegExpReplace($value[1], "\\\Z", "")
        $extended = @extended
        $w_value = StringRegExp($value[1], '\A"(.*)"', 1)
        If Not @error Then
            $type = "REG_SZ"
            $w_value = $w_value[0]
        Else
            $w_value = StringRegExp($value[1], "(.+):(.*)", 3)
            If @error Then ContinueLoop

            Switch $w_value[0]
                Case "dword"
                    $type = "REG_DWORD"
                Case "hex"
                    $type = "REG_BINARY"
                Case "hex(7)"
                    $type = "REG_MULTI_SZ"
                Case "hex(2)"
                    $type = "REG_EXPAND_SZ"
                Case Else
                    ContinueLoop
            EndSwitch
            $w_value=$w_value[1]
        EndIf

        If $extended > 0 Then
            $i += 1
            While 1
                $t_value = StringRegExp($arr_reg[$i], "\h*(.+)\h*", 1)
                $t_value = StringRegExpReplace($t_value[0], "\\\Z", "")
                $extended = @extended
                $w_value &= $t_value
                If $extended = 0 Then ExitLoop
                $i += 1
            WEnd
        EndIf       

        Switch $type
            Case "REG_SZ"
                $w_value = '"' & StringReplace($w_value, '\"', '""') & '"'
            Case "REG_DWORD"
                $w_value='"0x' & $w_value & '"'
            Case "REG_BINARY"
                If $w_value="" Then
                    $w_value='""'
                Else
                    $w_value = '"0x' & StringReplace($w_value, ",", "") & '"'
                Endif
            Case "REG_MULTI_SZ"
                $w_value = StringRegExpReplace(StringReplace($w_value, ",", ""), "00000000\Z", "")
                If $w_value="0000" OR $w_value="" Then
                    $w_value='""'
                Else
                    $w_value = StringReplace(BinaryToString("0x" & $w_value, 2), '"', '""')
                    $o_value = $w_value
                    $w_value = '"' & StringReplace($w_value, Chr(0), '" & Chr(10) & "') & '"'
                    If StringLeft($o_value, 1) = Chr(0) Then $w_value = StringTrimLeft($w_value, 5)
                    If StringRight($o_value, 1) = Chr(0) Then $w_value = StringTrimRight($w_value, 5)
                Endif
            Case "REG_EXPAND_SZ"                
                $w_value = StringRegExpReplace(StringReplace($w_value, ",", ""), "0000\Z", "")              
                $w_value = StringReplace(BinaryToString("0x" & $w_value, 2), '"', '""')
                $w_value = '"' & $w_value & '"'             
        EndSwitch

        $text &= 'RegWrite("' & $reg_path & '", "' & $value[0] & '", "' & $type & '", ' & $w_value & ')' & $crlf
        
        If TimerDiff($timer)>200 Then
            $timer=TimerInit()
            Tooltip("File: " & $filename & $crlf & "RegToAu3: " & Round($i/$arr_reg[0]*100) & "% completed",$DesktopWidth/2,$DesktopHeight-60,"",0,2)
        Endif       
    Next
    return $text
EndFunc   ;==>Generating

RegToAu3.au3

Edited by hunt
Link to comment
Share on other sites

  • 1 year later...

[HKEY_CLASSES_ROOT\pjpegfile\shell\open\command]

@="rundll32.exe C:\\WINDOWS\\system32\\shimgvw.dll,ImageView_Fullscreen %1"

>>>>

RegWrite("HKEY_CLASSES_ROOT\pjpegfile\shell\open\command", "", "REG_SZ", "rundll32.exe C:\\WINDOWS\\system32\\shimgvw.dll,ImageView_Fullscreen %1")

Edited by AZJIO
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...