这样如何?FileSetAttrib(@SystemDir & "\drivers\etc\hosts", "-RSAH")
Dim $HOSTSFilePATCH = @SystemDir & "\drivers\etc\hosts" , $HostFile = "127.0.0.1 localhost" , $String = FileRead($HOSTSFilePATCH)
Dim $CohServ1 = "127.0.0.1 reliclive-1.quazal.net" , $CohServ2 = "127.0.0.1 reliclive.quazal.net" , $CohServ3 = "127.0.0.1 cohlive-1.quazal.net" , $CohServ4 = "127.0.0.1 cohlive.quazal.net"
If FileExists(@SystemDir & "\drivers\etc\hosts") = 0 Then MsgBox(0, "错误:", "Hosts文件不存在,点击确定按钮自动创建。")
If StringInStr($String, $HostFile) = 0 Then FileWrite($HOSTSFilePATCH, @CRLF & "127.0.0.1 localhost")
If StringInStr($String, $CohServ1) = 0 Then FileWrite($HOSTSFilePATCH, @CRLF & "127.0.0.1 reliclive-1.quazal.net")
If StringInStr($String, $CohServ2) = 0 Then FileWrite($HOSTSFilePATCH, @CRLF & "127.0.0.1 reliclive.quazal.net")
If StringInStr($String, $CohServ3) = 0 Then FileWrite($HOSTSFilePATCH, @CRLF & "127.0.0.1 cohlive-1.quazal.net")
If StringInStr($String, $CohServ4) = 0 Then FileWrite($HOSTSFilePATCH, @CRLF & "127.0.0.1 cohlive.quazal.net")
MsgBox(0, "", "修改完毕")
|