Overblog Tous les blogs Top blogs Technologie & Science Tous les blogs Technologie & Science
Editer l'article Suivre ce blog Administration + Créer mon blog
MENU

vbs: Regedit : rename strKeyPath => strKeyPath & ".old"

Publié le par damcuvelier

 

rename = copy/rewrite/delete

 

    'save of key : key.old
    oReg.createKey HKEY_LOCAL_MACHINE, strKeyPath & ".old"
    'rewrite all value into new key
    oReg.EnumValues HKEY_LOCAL_MACHINE, strKeyPath, arrayValueNames, arrayValueTypes
        For i=0 To UBound(arrayValueNames)
            Select Case arrayValueTypes(i)
                Case REG_SZ
                oReg.SetStringValue HKEY_LOCAL_MACHINE, strKeyPath & ".old",arrayValueNames(i),readregvalue(strKeyPath,arrayValueNames(i),"SetStringValue")
                Case REG_EXPAND_SZ
                oReg.SetExpandedStringValue HKEY_LOCAL_MACHINE, strKeyPath & ".old",arrayValueNames(i),readregvalue(strKeyPath,arrayValueNames(i),"SetExpandedStringValue")
                Case REG_BINARY
                oReg.SetBinaryValue HKEY_LOCAL_MACHINE, strKeyPath & ".old",arrayValueNames(i),readregvalue(strKeyPath,arrayValueNames(i),"SetBinaryValue")
                Case REG_DWORD
                oReg.SetDWORDValue HKEY_LOCAL_MACHINE, strKeyPath & ".old",arrayValueNames(i),readregvalue(strKeyPath,arrayValueNames(i),"SetDWORDValue")
                Case REG_MULTI_SZ
                oReg.SetMultiStringValue HKEY_LOCAL_MACHINE, strKeyPath & ".old",arrayValueNames(i),readregvalue(strKeyPath,arrayValueNames(i),"SetMultiStringValue")
            End Select
        Next
   
    'delete key
    oReg.DeleteKey HKEY_LOCAL_MACHINE, strKeyPath

function readregvalue(KeyPath,value,ValueTypes)
    'read key.old?
    Select Case ValueTypes
        Case "SetStringValue"
        oReg.GetStringValue HKEY_LOCAL_MACHINE, KeyPath,value,readregvalue
        Case "SetExpandedStringValue"
        oReg.GetExpandedStringValue HKEY_LOCAL_MACHINE, KeyPath,value,readregvalue
        Case "SetBinaryValue"
        oReg.GetBinaryValue HKEY_LOCAL_MACHINE, KeyPath,value,readregvalue
        Case "SetDWORDValue"
        oReg.GetDWORDValue HKEY_LOCAL_MACHINE, KeyPath,value,readregvalue
        Case "SetMultiStringValue"
        oReg.GetMultiStringValue HKEY_LOCAL_MACHINE, KeyPath,value,readregvalue
    End Select
end function

Commenter cet article