中国DOS联盟论坛

中国DOS联盟

-- 联合DOS 推动DOS 发展DOS --

联盟域名:www.cn-dos.net  论坛域名:www.cn-dos.net/forum
DOS,代表着自由开放与发展,我们努力起来,学习FreeDOS和Linux的自由开放与GNU精神,共同创造和发展美好的自由与GNU GPL世界吧!

游客:  注册 | 登录 | 命令行 | 会员 | 搜索 | 上传 | 帮助 »
中国DOS联盟论坛 » DOS批处理 & 脚本技术(批处理室) » [已解决] 批处理智能输出文件除错 [不公开]
作者:
标题: [已解决] 批处理智能输出文件除错 [不公开] 上一主题 | 下一主题
chishingchan
银牌会员




积分 1282
发帖 538
注册 2002-11-2
状态 离线
『楼 主』:  [已解决] 批处理智能输出文件除错 [不公开]

以下是原程序,首先解释说明一下:这个是 BeTwin 系列版本补丁生成程序。
309、348、362 是 BeTwin 的版本号,5.00、5.1、5.2 分别是 Windows2000、WindowsXP、Windows2003 的版本号。
流程:
@echo off
:: 检测 BeTwin 的版本号
for /f "tokens=1-3 delims=." %%a in ('REG QUERY "HKLM\SOFTWARE\BeTwin" /v ProductVersion ^|findstr "ProductVersion"') do set PV=%%c
if "%PV%"=="" exit else goto %%PV%%

:309
:: 309 版本的输出文件
for /f "tokens=2*" %%a in ('REG QUERY "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion" /v CurrentVersion ^|findstr "CurrentVersion"') do set CV=%%b
if %CV%*==5.00* set win2000=174235
if %CV%*==5.1* set winxp=193915
if %CV%*==5.2* set win2003=192659
call :cs&call :%%CV%%&call :ce&exit

:348
:: 348 版本的输出文件
for /f "tokens=2*" %%a in ('REG QUERY "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion" /v CurrentVersion ^|findstr "CurrentVersion"') do set CV=%%b
if %CV%*==5.00* set win2000=171916
if %CV%*==5.1* set winxp=191196
if %CV%*==5.2* set win2003=190020
call :cs&call :%%CV%%&call :ce&exit

:362
:: 362 版本的输出文件
for /f "tokens=2*" %%a in ('REG QUERY "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion" /v CurrentVersion ^|findstr "CurrentVersion"') do set CV=%%b
if %CV%*==5.00* set win2000=175435
if %CV%*==5.1* set winxp=194555
if %CV%*==5.2* set win2003=193539
call :cs&call :%%CV%%&call :ce&exit

:cs
:: 公用开头程序行
>%PV%.vbs echo Set fso = CreateObject("Scripting.FileSystemObject")
>>%PV%.vbs echo set ado_stream = CreateObject("ADODB.Stream")
>>%PV%.vbs echo ado_stream.Type = 1

:5.00
>>%PV%.vbs echo iFile = fso.GetSpecialFolder(1) ^& "\BeTwinService2K.exe"
>>%PV%.vbs echo if fso.FileExists(iFile) Then
>>%PV%.vbs echo ado_stream.open
>>%PV%.vbs echo ado_stream.LoadFromFile iFile
>>%PV%.vbs echo ado_stream.position = %win2000%
>>%PV%.vbs echo ado_stream.Write HexToByte("EB")
>>%PV%.vbs echo ado_stream.SaveToFile iFile,2
>>%PV%.vbs echo ado_stream.Close
>>%PV%.vbs echo End if

:5.2
>>%PV%.vbs echo iFile = fso.GetSpecialFolder(1) ^& "\BeTwinService2003.exe"
>>%PV%.vbs echo if fso.FileExists(iFile) Then
>>%PV%.vbs echo ado_stream.open
>>%PV%.vbs echo ado_stream.LoadFromFile iFile
>>%PV%.vbs echo ado_stream.position = %win2003%
>>%PV%.vbs echo ado_stream.Write HexToByte("EB")
>>%PV%.vbs echo ado_stream.SaveToFile iFile,2
>>%PV%.vbs echo ado_stream.Close
>>%PV%.vbs echo End if

:5.1
>>%PV%.vbs echo iFile = fso.GetSpecialFolder(1) ^& "\BeTwinServiceXP.exe"
>>%PV%.vbs echo if fso.FileExists(iFile) Then
>>%PV%.vbs echo ado_stream.open
>>%PV%.vbs echo ado_stream.LoadFromFile iFile
>>%PV%.vbs echo ado_stream.position = %winxp%
>>%PV%.vbs echo ado_stream.Write HexToByte("EB")
>>%PV%.vbs echo ado_stream.SaveToFile iFile,2
>>%PV%.vbs echo ado_stream.Close
>>%PV%.vbs echo End if

:ce
:: 公用结尾程序行
>>%PV%.vbs echo set ado_stream = Nothing
>>%PV%.vbs echo Function HexToByte(hexStr)
>>%PV%.vbs echo set xmldom = Wscript.CreateObject("Microsoft.XMLDOM")
>>%PV%.vbs echo set byteObj= xmldom.createElement("byteObj")
>>%PV%.vbs echo byteObj.dataType = "bin.hex"
>>%PV%.vbs echo byteObj.nodeTypedValue = hexStr
>>%PV%.vbs echo HexToByte=byteObj.nodeTypedValue
>>%PV%.vbs echo End Function
例如:系统是WindowsXP、BeTwin 版本号是 362,生成的文件应该如下:

  Quote:
Set fso = CreateObject("Scripting.FileSystemObject")

set ado_stream = CreateObject("ADODB.Stream")
ado_stream.Type = 1

iFile = fso.GetSpecialFolder(1) & "\BeTwinServiceXP.exe"
if fso.FileExists(iFile) Then
ado_stream.open
ado_stream.LoadFromFile iFile
ado_stream.position = 194555
ado_stream.Write HexToByte("EB")
ado_stream.SaveToFile iFile,2
ado_stream.Close
End if

set ado_stream = Nothing

Function HexToByte(hexStr)
set xmldom = Wscript.CreateObject("Microsoft.XMLDOM")
set byteObj= xmldom.createElement("byteObj")
byteObj.dataType = "bin.hex"
byteObj.nodeTypedValue = hexStr
HexToByte=byteObj.nodeTypedValue
End Function

请问如何修改?谢谢!

[ Last edited by chishingchan on 2008-5-2 at 01:27 AM ]

2008-5-1 23:38
查看资料  发短消息 网志   编辑帖子  回复  引用回复

请注意:您目前尚未注册或登录,请您注册登录以使用论坛的各项功能,例如发表和回复帖子等。


可打印版本 | 推荐给朋友 | 订阅主题 | 收藏主题



论坛跳转: