找回密码
 加入
搜索
查看: 2897|回复: 1

报告一个第一汉化AUTOIT_3.3.3.3.exe的BUG

[复制链接]
发表于 2010-1-19 16:09:23 | 显示全部楼层 |阅读模式
本帖最后由 boyhong 于 2010-1-19 16:33 编辑

报告一个第一汉化AUTOIT_3.3.3.3.exe的BUG。
如下,我拿:AUTOIT_3.3.2.0-1.exe 生成,运行,得到我要的结果。拿AUTOIT_3.3.3.3.exe生成,运行,不能得到我想要的运行之结果。
也不报错。我也不知什么原因。

EG:
#Include <File.au3>
jctcohosts()
Func jctcohosts()
Dim $ajcRecords,$ajcAarry,$jajcAarry
$yjc =1008
$pingceridns=ping("220.181.6.81",250)
If Not _FileReadToArray(@WindowsDir&"\system32\drivers\etc\hosts",$ajcRecords) Then
   MsgBox(4096,"= 程序出错 =", " 没有找到HOSTS文件     错误代码是:" & @error)
   Exit
EndIf
$filetest = FileOpen(@WindowsDir&"\system32\drivers\etc\hosts",0)
$line = FileReadLine($filetest,$ajcRecords[0])
if ($line<>"") then
        $filetest = FileOpen(@WindowsDir&"\system32\drivers\etc\hosts",1)
        FileWriteLine($filetest,"")
endif
FileClose($filetest)
_FileReadToArray(@WindowsDir&"\system32\drivers\etc\hosts",$ajcAarry)

For $jx = 1 to $ajcAarry[0]
        if  $ajcAarry[$jx] ="172.16.136.36   www.XXXX.com.cn" Then
                 $yjc = 1009
         EndIf        
 Next

if $pingceridns then
    if  ($yjc=1008) then
                _FileWriteToLine(@WindowsDir&"\system32\drivers\etc\hosts", $ajcAarry[0], "172.16.136.36   www.XXXX.com.cn", 1)
                $cctest = 1009
        EndIf
Else
        if ($yjc=1009)  then
MsgBox(64,"","测试,没有PING通。并且检测到了之前改了hosts文件")
_FileSRER2Line(@WindowsDir&'\system32\drivers\etc\hosts', '172.16.136.36   www.XXXX.com.cn', '', 0)
_FileSRER2Line(@WindowsDir&"\system32\drivers\etc\hosts") ;删除文件中的所有空行
    EndIf
        SplashOff()
EndIf
SplashOff()
EndFunc

;==========================================================================================
; 说明: 按指定的关键字替换或删除文本行,可选择是否使用正则表达式,是否写新文件等。
; 语法: _FileSRER2Line('文件路径'[, '搜索字符'[, '替换'[, 匹配标志[, 正则标志[, 写入标志]]]]])
; 参数: 可选参数:如'搜索字符'字符为空(默认)则删除所有空行。
;    可选参数:如'替换'字符为空(默认)则删除匹配行,且不会留下空行。
;    可选参数:匹配标志 = 1 :整行需完全匹配(默认);匹配标志 = 0 :行中只需包含关键字。
;    可选参数:使用正则标志 = 1 使用正则(默认),为 0 不使用正则,使用原始字符串匹配。
;    可选参数:写入标志 = '' 写入原文件(默认);不为空则写入指定文件;= 0 仅返回不写入。
; 注意: 本函数以行作为操作单位,即不管在一行中含有几处关键字均按一个替换单位操作。
; 返回值:返回替换后的字符串。替换次数保存在@extended宏中。
; 作者: Afan -- http://www.autoitx.com/forum.php?mod=viewthread&tid=11801
;=====================================================================================start
Func _FileSRER2Line($File, $pattern = '', $replace = '', $flag = 1, $SRE = 1, $Write = '')
        Local $sFile = String(FileRead($File)), $strqhz = '', $extended = 0, $sRER, $strZY
        If $pattern = '' Then 
                $sRER = StringRegExpReplace($sFile, '\r\n(?=\r\n)|\r\n$', '') 
                $extended = $extended + @extended
                $sRER = StringRegExpReplace($sRER, '^\r\n', '') 
        Else
                If $SRE = 0 Then 
                        $strZY = '(\.|\||\*|\?|\+|\(|\)|\{|\}|\[|\]|\^|\$|\\)'
                        $pattern = StringRegExpReplace($pattern, $strZY, '\\$1') 
                        $replace = StringRegExpReplace($replace, $strZY, '\\$1') 
                EndIf
                If $flag = 0 Then $strqhz = '.*'
                Local $patternWZ = $strqhz & $pattern & $strqhz
                If $replace <> '' Then 
                        $sRER = StringRegExpReplace($sFile, '^' & $patternWZ & '(?=\r\n)', $replace, 1)
                        $extended = $extended + @extended
                        $pattern = @CRLF & $patternWZ & '(?=\r\n)|\r\n' & $patternWZ & '$'
                        $sRER = StringRegExpReplace($sRER, $pattern, @CRLF & $replace)
                Else 
                        $sRER = StringRegExpReplace($sFile, '^' & $patternWZ & @CRLF, $replace, 1)
                        $extended = $extended + @extended
                        $pattern = @CRLF & $patternWZ & '(?=\r\n)|\r\n' & $patternWZ & '$'
                        $sRER = StringRegExpReplace($sRER, $pattern, $replace)
                EndIf
        EndIf
        $extended = $extended + @extended
        If $Write = '' And $Write <> '0' Then
                $sTmp = FileOpen($File, 2)
                FileWrite($sTmp, $sRER)
                FileClose($sTmp)
        ElseIf $Write <> '' Then
                $sTmp = FileOpen($Write, 2)
                FileWrite($sTmp, $sRER)
                FileClose($sTmp)
        EndIf
        SetExtended($extended)
        Return $sRER
        EndFunc   ;==>_FileSRER2Line;==========================================================================================
 楼主| 发表于 2010-1-19 16:34:52 | 显示全部楼层
PING不能的情况下:AUTOIT_3.3.2.0-1.exe 能删除了;AUTOIT_3.3.3.3.exe却在PING拔了网线不能PING的情况下删不了////
您需要登录后才可以回帖 登录 | 加入

本版积分规则

QQ|手机版|小黑屋|AUTOIT CN ( 鲁ICP备19019924号-1 )谷歌 百度

GMT+8, 2024-5-5 03:35 , Processed in 0.070359 second(s), 19 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表