本帖最后由 apang 于 2014-11-7 10:18 编辑
回复 5# 867258173
导出到不同的reg文件- @set @n=0;/* & echo off & setlocal enabledelayedexpansion
- md "reg" 2>nul
- pushd "reg\"
- (for %%a in (HKLM HKCU HKCR HKU HKCC) do (
- set "n="
- for /f "delims=" %%b in ('reg query "%%a" /s /f "txt" /k') do (
- set /a n+=1
- reg export "%%b" %%a_!n!.reg
- )
- )) 2>nul
- dir /b *.reg | cscript -nologo -e:jscript "%~0"
- start "" ".\"
- pause & exit/b & rem */
-
- fso = new ActiveXObject("Scripting.FileSystemObject");
- while (!WScript.StdIn.AtEndOfstream) {
- file = WScript.StdIn.ReadLine();
- f = fso.OpenTextFile(file, 1, false, -1);
- txt = f.Readall();
- f.Close();
- txt = /[\s\S]*?^\[[\s\S]*?(?=^\[)/m.exec(txt + "\r\n[")[0];
- fso.OpenTextFile(file, 2, true, -1).Write(txt);
- }
复制代码 导出并合并成一个reg文件(修改第2、3行变量的值)- @set @n=0;/* & echo off
- set "keyword=txt"
- set "regfile=Result.reg"
-
- cd.>"%regfile%"
- (for %%a in (HKLM HKCU HKCR HKU HKCC) do (
- for /f "delims=" %%b in ('reg query "%%a" /s /f "%keyword%" /k')do (
- reg export "%%b" $
- copy /b "%regfile%" + $ "%regfile%"
- del $
- )
- )) 2>nul
-
- for %%a in ("%regfile%") do (
- if "%%~za" NEQ "0" (
- cscript -nologo -e:jscript "%~0" "%regfile%"
- start NotePad "%regfile%"
- ) else del "%regfile%"
- )
- pause & exit/b & rem */
-
- str = "Windows Registry Editor Version 5.00\r\n";
- regfile = WScript.Arguments(0);
- fso = new ActiveXObject("Scripting.FileSystemObject");
- f = fso.OpenTextFile(regfile, 1, false, -1);
- ar = f.Readall().split(str);
- f.Close();
- re = /^\[[\s\S]*?(?=^\[)/m;
- ar[0] = str + "\r\n";
- for (i=1; i<ar.length; i++) {
- ar[i] = re.exec(ar[i] + "\r\n[")[0];
- }
- fso.OpenTextFile(regfile, 2, true, -1).Write(ar.join(""))
复制代码
|