|  | 
 
| bsijl 新手上路
 
  
 
 
 
 积分 15
 发帖 7
 注册 2006-2-12
 状态 离线
 | 
| 『楼 主』:
 批处理删除XP输入法问题!请dos高手解决
 
使用 LLM 解释/回答一下 
 
 
***********************************************************echo rip fareast ime
 rem 把Unicode编码的intl.inf文件转换为UTF8编码,这样普通的程序可以用类似处理英文的方法来处理
 copy i386\intl.inf intl.inf
 recode u2..u8 intl.inf
 rem  在intl.inf文件中搜索带有[ime]这样的行
 findstr /i ^^\[.*ime intl.inf |findstr /i /V \[FE_CONIME\] | findstr /i /V \[EA_IME_SHARED\] >tmp.imerfall.txt
 rem 找出所有的和输入法相关的文件名字存入tmp.IMEfiles.txt
 for /F "tokens=1,2,3* delims=[]" %%i in ('findstr /i /V LGReg tmp.imerfall.txt') do (
 sed -n -e  /^^\[%%i\]/,/^^\[.*\]/p intl.inf | sed -e  /^^\[.*\]/d   -e /^^$/d>>tmp.IMEfiles.txt
 )
 rem 找出所有和输入法相关的文件名字的注册表项存储为tmp.imeLGReg.txt,略过了英文的输入法的注册报条目
 for /F "tokens=1,2,3* delims=[]" %%i in ('findstr /i LGReg tmp.imerfall.txt') do (
 sed -n -e  /^^\[%%i\]/,/^^\[.*\]/p intl.inf | sed -e  /^^\[.*\]/d   -e /^^$/d |findstr /V 00000804 |findstr /V 00000404>>tmp.imeLGReg.txt
 )
 rem 删除intl.inf中和ime相关的注册表项
 fgrep -v  -F -f tmp.imeLGReg.txt intl.inf>tmp.intl.inf
 rem 删除可能存在的空格
 if exist xxx.tmp.txt del /Q xxx.tmp.txt
 for /F "eol=; tokens=1* delims=, " %%x in (tmp.imefiles.txt)  do @echo %%x>>xxx.tmp.txt
 move /Y xxx.tmp.txt tmp.imefiles.txt
 
 rem 把所有要删除的文件都存到allfilefordel.txt中
 type tmp.imefiles.txt>>allfilefordel.txt
 rem 从intl.inf删除对这些输入法文件的引用
 findstr /V /i /B /G:tmp.imefiles.txt tmp.intl.inf>intl.inf
 rem 把intl.inf转换为unicode编码
 recode u8..u2/21 intl.inf
 rem 覆盖在i386目录的intl.inf文件
 move /Y INTL.INF I386\intl.inf
 rem 从txtsetup.sif删除对这些输入法文件的引用
 findstr /V /i /B /G:tmp.imefiles.txt i386\txtsetup.sif>tmp.txtsetup.sif
 move  /Y tmp.txtsetup.sif i386\txtsetup.sif
 rem 从dosnet.inf删除对这些输入法文件的引用
 findstr /V /i /B /G:tmp.imefiles.txt i386\dosnet.inf>tmp.dosnet.inf
 move  /Y tmp.dosnet.inf i386\dosnet.inf
 rem  复制HIVESYS.INF文件
 copy I386\HIVESYS.INF HIVESYS.INF
 rem 把HIVESYS.INF转换为utf8编码
 recode u2..u8 HIVESYS.inf
 rem 需要删除的注册表项
 echo HKLM,"SYSTEM\CurrentControlSet\Control\Keyboard Layouts\E0010804">tmp.imereg.lst
 echo HKLM,"SYSTEM\CurrentControlSet\Control\Keyboard Layouts\E0020804">>tmp.imereg.lst
 echo HKLM,"SYSTEM\CurrentControlSet\Control\Keyboard Layouts\E0030804">>tmp.imereg.lst
 echo HKLM,"SYSTEM\CurrentControlSet\Control\Keyboard Layouts\E0050804">>tmp.imereg.lst
 echo HKLM,"SYSTEM\CurrentControlSet\Control\Keyboard Layouts\E00E0804">>tmp.imereg.lst
 echo HKLM,"SYSTEM\CurrentControlSet\Control\Keyboard Layouts\00010409">>tmp.imereg.lst
 echo HKLM,"SYSTEM\CurrentControlSet\Control\Keyboard Layouts\00010409">>tmp.imereg.lst
 echo HKLM,"SYSTEM\CurrentControlSet\Control\Keyboard Layouts\00010409">>tmp.imereg.lst
 echo HKLM,"SYSTEM\CurrentControlSet\Control\Keyboard Layouts\00020409">>tmp.imereg.lst
 echo HKLM,"SYSTEM\CurrentControlSet\Control\Keyboard Layouts\00020409">>tmp.imereg.lst
 echo HKLM,"SYSTEM\CurrentControlSet\Control\Keyboard Layouts\00020409">>tmp.imereg.lst
 echo HKLM,"SYSTEM\CurrentControlSet\Control\Keyboard Layouts\00030409">>tmp.imereg.lst
 echo HKLM,"SYSTEM\CurrentControlSet\Control\Keyboard Layouts\00030409">>tmp.imereg.lst
 echo HKLM,"SYSTEM\CurrentControlSet\Control\Keyboard Layouts\00030409">>tmp.imereg.lst
 echo HKLM,"SYSTEM\CurrentControlSet\Control\Keyboard Layouts\00040409">>tmp.imereg.lst
 echo HKLM,"SYSTEM\CurrentControlSet\Control\Keyboard Layouts\00040409">>tmp.imereg.lst
 echo HKLM,"SYSTEM\CurrentControlSet\Control\Keyboard Layouts\00040409">>tmp.imereg.lst
 rem 从HIVESYS.INF中删除上面的注册表项
 findstr /i /v /G:tmp.imereg.lst HIVESYS.INF >tmp.hivesys.inf
 move /Y tmp.hivesys.inf  hivesys.inf
 rem 把hivesys.inf变换为unicode编码
 recode u8..u2/21 hivesys.inf
 rem 覆盖i386目录的 hivesys.inf
 move /Y HIVESYS.INF I386\HIVESYS.INF
 rem 删除临时文件
 del tmp.*
 ***********************************************************
 findstr /V /i /B /G:tmp.imefiles.txt i386\dosnet.inf>tmp.dosnet.inf这句从dosnet.inf删除对这些输入法文件的引用不好用啊!tmp.imefiles.txt里是单纯的文件名,dosnet.inf里是文件名前加了个d1,,这样也不能比较啊,不好用!而且我发现dosnet.inf也有问题,可能是编码的问题,我用findstr /v /i /b /G:dosnet.inf dosnet.inf居然出来结果了,是同一个文件啊,一样一样的,怎么会出来结果呢?用recode u2..u8 dosnet.inf也不行,还是一样出现结果!请问这是怎么回事?
 
 
 
 
 
附件
1:  dosnet.rar (2006-2-12 01:56, 15.02 KiB, 下载附件所需积分 1 点
,下载次数: 33) 
 |  | 
|  2006-2-12 01:56 |  | 
|  | 
 
| willsort 元老会员
 
          Batchinger
 
 
 积分 4432
 发帖 1512
 注册 2002-10-18
 状态 离线
 | 
| 『第 2 楼』:
 
 
使用 LLM 解释/回答一下 
 
 
Re bsijl:
 因为你的 findstr 使用了 /B ,所以文件名与d1+文件名必然因为行首不同而匹配失败,去掉这个开关应该就可以了。
 
 至于 findstr /v /i /b /G:dosnet.inf dosnet.inf 的结果确实比较奇怪,我测试了一些批处理文件,结果大都与原文不同,而不使用 /b 也会得到不一样的结果,估计是 /G 参数的问题,以前没有注意过这个参数。
 
 
 
 
 
 |  
                  |  ※ Batchinger 致 Bat Fans:请访问 批处理编程的异类 ,欢迎交流与共享批处理编程心得!
 |  | 
|  2006-2-12 10:48 |  | 
|  | 
 
| bsijl 新手上路
 
  
 
 
 
 积分 15
 发帖 7
 注册 2006-2-12
 状态 离线
 | 
| 『第 3 楼』:
 
 
使用 LLM 解释/回答一下 
 
 
那就没办法了,实际上这findstr /V /i /B /G:tmp.imefiles.txt i386\dosnet.inf>tmp.dosnet.inf可以不用的,交给NLITE去做就可以了,唉!还有一个问题就是fgrep删掉条件行后文件变得没有格式了,用FOR删除空格后,文件里的中文会变成乱码!经过试验发现出现这样的情况好像是被处理的文件第一行是空行,删掉这一行后,用FORG再整理格式就没问题了,这是怎么回事?请解答
 
 
 
 
 |  | 
|  2006-2-13 20:06 |  | 
|  | 
 
| willsort 元老会员
 
          Batchinger
 
 
 积分 4432
 发帖 1512
 注册 2002-10-18
 状态 离线
 | 
| 『第 4 楼』:
 
 
使用 LLM 解释/回答一下 
 
 
Re bsijl:
 fgrep 这个工具没有接触过,不知其中的细节。forg 是否应为 for ?
 
 至于 for 删除空格出现乱码的问题,我使用你的语句测试过我本地的一些文本文件,没有遇到此问题,只是会删除其中的所有空行,包括行首的空格,这是 for /f 已知的特性。所以我怀疑你的问题与文本的编码方式有关,导致删除空行时影响到下一行,使此后整个文本的编码错位。
 
 如果你能提供 tmp.imefiles.txt 和 xxx.tmp.txt 两个文件,我判断问题会更有把握。
 
 
 
 
 
 |  
                  |  ※ Batchinger 致 Bat Fans:请访问 批处理编程的异类 ,欢迎交流与共享批处理编程心得!
 |  | 
|  2006-2-13 21:45 |  | 
|  | 
 
| bsijl 新手上路
 
  
 
 
 
 积分 15
 发帖 7
 注册 2006-2-12
 状态 离线
 |  | 
|  2006-2-21 16:59 |  | 
|  | 
 
| wua0550 新手上路
 
  
 
 
 
 积分 2
 发帖 1
 注册 2007-1-15
 状态 离线
 |  | 
|  2007-5-31 15:06 |  | 
|  | 
 
| tider1984 新手上路
 
  
 
 
 
 积分 6
 发帖 3
 注册 2007-1-2
 状态 离线
 |  | 
|  2007-8-21 13:15 |  | 
|  | 
 
| tider1984 新手上路
 
  
 
 
 
 积分 6
 发帖 3
 注册 2007-1-2
 状态 离线
 |  | 
|  2007-8-21 13:20 |  | 
|  | 
 
| zhanghdong 新手上路
 
  
 
 
 
 积分 1
 发帖 1
 注册 2009-4-15
 状态 离线
 |  | 
|  2010-3-9 00:17 |  | 
|  | 
 
| yuan53770 初级用户
 
   
 
 
 
 积分 67
 发帖 40
 注册 2007-11-5
 状态 离线
 |  | 
|  2010-11-21 00:33 |  |