|
哦,那我理解有误,是要在第二行插入 "2"="E0200804",第三行固定为 "3"="E0040804" 是吗?
再看这样对不对:
--------------------------------------------------分割线-----------------------------------------------
@echo off
setlocal enabledelayedexpansion
if exist %temp%\tmp*.txt del %temp%\tmp*.txt>nul
set aa=0 && set bb=0
reg export "hkcu\Keyboard Layout\Preload" %temp%\tmp1.txt
for /f "skip=3 tokens=1,2* delims==" %%a in ('type %temp%\tmp1.txt') do (
set /a aa=!aa!+1
echo "!aa!"=%%b>>%temp%\tmp2.txt
if "!aa!"=="1" echo "2"="E0200804">>%temp%\tmp2.txt && set /a aa=!aa!+1
)
echo Windows Registry Editor Version 5.00>c:\my.reg
echo.>>c:\my.reg
echo [HKEY_CURRENT_USER\Keyboard Layout\Preload]>>c:\my.reg
for /f "tokens=1,2* delims==" %%a in ('type %temp%\tmp2.txt') do (
set /a bb=!bb!+1
if "!bb!"=="3" (set k1=%%b && echo "3"="E0040804">>c:\my.reg) else (
if /i %%b=="E0040804" (echo "!bb!"=!k1!>>c:\my.reg) else (
echo "!bb!"=%%b>>c:\my.reg
)))
pause
--------------------------------------------------分割线-----------------------------------------------
(匆忙写的,比较繁琐,应该可以优化一下的) |
|