经过几天摸索其本解决安装目录下KuGoo.xml文件的修改问题.
要说明一下刚开始我没注意到安装目录下的KuGoo.xml文件是UTF-8编码的.
一开始用9楼tireless兄写的代码进行测试虽然要更换的字符串是可以更换成功了.
但是有的字符却变成乱码.特别是中文部分....出现这个情况.
我以为处理xml文件格式可能需要用xml文件的编辑工具才能完成
但是我对xml文件的编辑工具又不了解(如lxmxn版主所说的关于XML的问题还是用XML的工具比较合适.需要了解一点Xpath方面的知识。)
后来看到14楼zh159兄说:xml文件是UTF-8编码的,所以不能用BAT来处理
我就尝试把KuGoo.xml文件由UTF-8编码转成ANSI编码然后再看看行不行
搜索论坛找到fastslz兄写的文章.用他写的vbs代码将UTF-8编码转成ANSI编码.然后再按9楼tireless写的代码进行测试.
果然成功了.没有出现乱码.(因为乱码的KuGoo.xml文件.酷狗音乐2008的kugoo.exe是无法识别的.)
下面是我综合修改后的代码.希望对有需要的人有用
(非常感谢tireless zh159 fastslz lxmxn版主)
兰色部分是fastslz兄写的VBS代码稍作一点修改
(作用是将KuGoo.xml文件由UTF-8编码转成ANSI编码)
红色部分是9楼tireless兄写的代码
(作用是将<Plugin ModulesCount="0"/>改成
<Plugin PluginPath="C:\Program Files\KuGou\KuGou2008\ktv98\Plugins\" ModulesCount="1" Module0="dsp_ktv1.dll|0"/>
@echo off
taskkill /f /im KuGoo.exe
Echo Set objArgs = WScript.Arguments > UTF82ANSI.vbs
Echo For I = 0 To objArgs.Count - 1 >> UTF82ANSI.vbs
Echo FileUrl = objArgs(I) >> UTF82ANSI.vbs
Echo Call WriteToFile(FileUrl, ReadFile(FileUrl, "UTF-8"), "GB2312") >> UTF82ANSI.vbs
Echo Next >> UTF82ANSI.vbs
Echo Function ReadFile(FileUrl, CharSet) >> UTF82ANSI.vbs
Echo Dim Str >> UTF82ANSI.vbs
Echo Set stm = CreateObject("Adodb.Stream") >> UTF82ANSI.vbs
Echo stm.Type = 2 >> UTF82ANSI.vbs
Echo stm.mode = 3 >> UTF82ANSI.vbs
Echo stm.charset = CharSet >> UTF82ANSI.vbs
Echo stm.Open >> UTF82ANSI.vbs
Echo stm.loadfromfile FileUrl >> UTF82ANSI.vbs
Echo Str = stm.readtext >> UTF82ANSI.vbs
Echo stm.Close >> UTF82ANSI.vbs
Echo Set stm = Nothing >> UTF82ANSI.vbs
Echo ReadFile = Str >> UTF82ANSI.vbs
Echo End Function >> UTF82ANSI.vbs
Echo Function WriteToFile (FileUrl, Str, CharSet) >> UTF82ANSI.vbs
Echo Set stm = CreateObject("Adodb.Stream") >> UTF82ANSI.vbs
Echo stm.Type = 2 >> UTF82ANSI.vbs
Echo stm.mode = 3 >> UTF82ANSI.vbs
Echo stm.charset = CharSet >> UTF82ANSI.vbs
Echo stm.Open >> UTF82ANSI.vbs
Echo stm.WriteText Str >> UTF82ANSI.vbs
Echo stm.SaveToFile FileUrl, 2 >> UTF82ANSI.vbs
Echo stm.flush >> UTF82ANSI.vbs
Echo stm.Close >> UTF82ANSI.vbs
Echo Set stm = Nothing >> UTF82ANSI.vbs
Echo End Function >> UTF82ANSI.vbs
for /f "delims=" %%a in ('dir /s /b /a-d "C:\Program Files"\KuGou\KuGou2008\KuGoo.xml') do UTF82ANSI.vbs "%%a"
set xmlpath="C:\Program Files\KuGou\KuGou2008\KuGoo.xml"
for /f "tokens=1,*" %%a in ('type %xmlpath%') do (
if "%%a" neq "<Plugin" (>>%temp%\#.xml echo.%%a%%b) else (
>>%temp%\#.xml echo.^<Plugin PluginPath="C:\Program Files\KuGou\KuGou2008\ktv98\Plugins\" ModulesCount="1" Module0="dsp_ktv1.dll|0"/^>
)
)
move /y %temp%\#.xml %xmlpath%
del UTF82ANSI.vbs
exit /b
本帖最近评分记录
(共 1 条)
点击查看详情
| 评分人 | 分数 | 时间 |
| HAT |
+2 |
2008-12-08 13:58 |
CN-DOS批处理室非官方QQ群①:61377162 ②:70174619 ③:75070617
请勿尝试同时加多个群