Jump to content

How replace some strings in registry file


SebaM
 Share

Recommended Posts

Oh thanks. Maybe also you can clean:

This works OK

Why not

func inicheck($n,$max)
    If IniRead("batUSB_CONFIG.ini","PROGRAMS","Count","0") > $n Then
        If IniRead("batUSB_CONFIG.ini","PROGRAMS",$n+1 & ".Mode","") = 0 OR IniRead("batUSB_CONFIG.ini","PROGRAMS",$n+1 & ".Mode","") = 1 Then
            Run(IniRead("batUSB_CONFIG.ini","PROGRAMS",$n+1 & ".ProgramPath","") & " " & IniRead("batUSB_CONFIG.ini","PROGRAMS",$n+1 & ".Switch",""))
            if $n<$max then inicheck($n+1,$max)
        EndIf
    EndIf
EndFunc

func iniCheck2($n,$max)
    If IniRead("batUSB_CONFIG.ini","REGISTRY","Count","0") > $n Then
        _ssBackup(($n+1) & ".Name",($n+1) & ".Key")
        RegDelete (IniRead("batUSB_CONFIG.ini","REGISTRY",($n+1) & ".Key",""))
        _ssRegFAdd(IniRead("batUSB_CONFIG.ini","REGISTRY",($n+1) & ".Name",""))
        if $n<$max then iniCheck2($n+1,$max)
    EndIf
EndFunc


Func OnAutoItStart ( )
    inicheck(0,9)
    iniCheck2(0,9)
EndFunc
Edited by tresa
Link to comment
Share on other sites

Something is wrong in func cleanUp($n). I have info that variable $ssFName used without being declared.

here i modified the code

Func _sRegBackup($ssFName,$KEYEND)
    Local $regkeybs = IniRead("batUSB_CONFIG.ini", "REGISTRY", $KEYEND, "")
    Local $srege = @WindowsDir & "\regedit.exe /a " & Chr("34") & $regfolder & "\" & $ssFName & "1.reg" & Chr("34") & " " & IniRead("batUSB_CONFIG.ini", "REGISTRY", $KEYEND, "")
    Local $sregbackups = @WindowsDir & "\regedit.exe /s " & Chr("34") & $regfolder & "\backup_" & $ssFName & ".reg" & Chr("34")
    Local $sregbackupe = @WindowsDir & "\regedit.exe /a " & Chr("34") & $regfolder & "\backup_" & $ssFName & ".reg" & Chr("34") & " " & IniRead("batUSB_CONFIG.ini", "REGISTRY", $KEYEND, "")
    Local $n
    for $n=5 to 1 step-1
        If FileExists($regfolder & "\" & $ssFName & $n & ".reg") then ExitLoop
    next
    if $n>0 then   
        cleanUp($n,$ssFName )
        RunWait ($srege, $regfolder, @SW_HIDE )
        RegDelete($regkeybs)
        RunWait ($sregbackups, $regfolder, @SW_HIDE )
        FileDelete ($regfolder & "\backup_" & $ssFName & ".reg" )
    EndIf
EndFunc

func cleanUp($n,$fnName)
    FileMove($regfolder & "\" & $fnName& $n & ".reg", $regfolder & "\" & $fnName & ($n+1) & ".reg")
    if $n=1 then return
    FileDelete ($regfolder & "\" & $fnName& $n & ".reg" )
    cleanUp($n-1)
EndFunc
Edited by tresa
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...