回复 19# yuanyannian
还是保存到reg文件吧,少一点弯弯绕- Dim s1, s2, strSection, arField, arValue, arPath
- s1 = "HKEY_CURRENT_USER\"
- s2 = "HKEY_LOCAL_MACHINE\"
- strSection = "Strings"
- arField = Array("BIOS", "NDIS", "GULIM")
- arValue = Array("yyn1", "yyn2", "yyn3")
- arPath = Array(s1 & "yyn\Desktop", s1 & "yyn\Test", s2 & "Software\Test\yyn")
-
- Dim fso, txt, re, i, regData
- Set fso = CreateObject("Scripting.FileSystemObject")
- txt = fso.OpenTextFile("HIVESFT.INF", 1, false, -1).ReadAll
- txt = txt & vbCrLf & "["
-
- Set re = New RegExp
- re.Pattern = "^ *\[" & strSection & "] *$[\s\S]*?(?=^ *\[)"
- re.IgnoreCase = true
- re.Global = true
- re.MultiLine = true
- If Not re.Test(txt) Then WScript.Quit
- txt = re.Execute(txt)(0)
-
- For i = 0 to UBound(arField)
- re.Pattern = "^ *" & arField(i) & " *= *("".*"")"
- If re.Test(txt) Then
- regData = re.Execute(txt)(0).SubMatches(0)
- s = s & "[" & arPath(i) & "]" & vbCrLf
- s = s & """" & arValue(i) & """=" & regData & vbCrLf
- s = s & vbCrLf
- End If
- Next
-
- s = "Windows Registry Editor Version 5.00" & vbCrLf & vbCrLf & s
- fso.OpenTextFile("Result.reg", 2, true, -1).Write s
复制代码
|