luyuwen3 发表于 2024-9-22 14:38:17

求助删除hpst

# Copyright (c) 1993-2009 Microsoft Corp.
#
# This is a sample HOSTS file used by Microsoft TCP/IP for Windows.
#
# This file contains the mappings of IP addresses to host names. Each
# entry should be kept on an individual line. The IP address should
# be placed in the first column followed by the corresponding host name.
# The IP address and the host name should be separated by at least one
# space.
#
# Additionally, comments (such as these) may be inserted on individual
# lines or following the machine name denoted by a '#' symbol.
#
# For example:
#
#      102.54.94.97   rhino.acme.com          # source server
#       38.25.63.10   x.acme.com            # x client host

# localhost name resolution is handled within DNS itself.
#        127.0.0.1       localhost
#        ::1             localhost
132311231231
127.0.0.1 mail.casetekcorp.com
127.0.0.1 csmail.casetekcorp.com
127.0.0.1 cjsmail.casetekcorp.com
127.0.0.1 yrkmail.casetekcorp.com
127.0.0.1 autodiscover.casetekcorp.com
127.0.0.1 autodiscover.intra.casetekcorp.com怎么写删除127.0.0.1 mail.casetekcorp.com
127.0.0.1 csmail.casetekcorp.com
127.0.0.1 cjsmail.casetekcorp.com
127.0.0.1 yrkmail.casetekcorp.com
127.0.0.1 autodiscover.casetekcorp.com
127.0.0.1 autodiscover.intra.casetekcorp.com这个具体咋写写了删除不了 ,还望大神指点指点

smallan 发表于 2024-9-22 16:25:01

本帖最后由 smallan 于 2024-9-22 16:27 编辑

#include <File.au3>
#include <Array.au3>
Local $aRetArray, $sFilePath = "C:\windows\system32\drivers\etc\hosts", $sDelString = "127.0.0.1 mail.casetekcorp.com"
FileOpen($sFilePath)
_FileReadToArray($sFilePath, $aRetArray)
$iSearch = _ArraySearch($aRetArray, $sDelString)
_FileWriteToLine($sFilePath, $iSearch, "", 1)
FileClose($sFilePath)


3131210 发表于 2024-9-23 12:21:56

Local $sSource = _
                '# Copyright (c) 1993-2009 Microsoft Corp.' & @CRLF & _
                '#' & @CRLF & _
                '# This is a sample HOSTS file used by Microsoft TCP/IP for Windows.' & @CRLF & _
                '#' & @CRLF & _
                '# This file contains the mappings of IP addresses to host names. Each' & @CRLF & _
                '# entry should be kept on an individual line. The IP address should' & @CRLF & _
                '# be placed in the first column followed by the corresponding host name.' & @CRLF & _
                '# The IP address and the host name should be separated by at least one' & @CRLF & _
                '# space.' & @CRLF & _
                '#' & @CRLF & _
                '# Additionally, comments (such as these) may be inserted on individual' & @CRLF & _
                "# lines or following the machine name denoted by a '#' symbol." & @CRLF & _
                '#' & @CRLF & _
                '# For example:' & @CRLF & _
                '#' & @CRLF & _
                '#      102.54.94.97   rhino.acme.com          # source server' & @CRLF & _
                '#       38.25.63.10   x.acme.com            # x client host' & @CRLF & @CRLF & _
                '# localhost name resolution is handled within DNS itself.' & @CRLF & _
                '#      127.0.0.1       localhost' & @CRLF & _
                '#      ::1             localhost' & @CRLF & _
                '132311231231' & @CRLF & _
                '127.0.0.1 mail.casetekcorp.com' & @CRLF & _
                '127.0.0.1 csmail.casetekcorp.com' & @CRLF & _
                '127.0.0.1 cjsmail.casetekcorp.com' & @CRLF & _
                '127.0.0.1 yrkmail.casetekcorp.com' & @CRLF & _
                '127.0.0.1 autodiscover.casetekcorp.com' & @CRLF & _
                '127.0.0.1 autodiscover.intra.casetekcorp.com' & @CRLF
;~ MsgBox(0, '源字符串', $sSource)
Local $sSRERe = StringRegExpReplace($sSource, '(?mi)\r\n^.+?\.casetekcorp.+?$', '')
MsgBox(0, '替换结果', $sSRERe)
页: [1]
查看完整版本: 求助删除hpst