找回密码
 加入
搜索
查看: 128|回复: 2

求助删除hpst

[复制链接]
发表于 2024-9-22 14:38:17 | 显示全部楼层 |阅读模式
# 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这个具体咋写写了删除不了 ,还望大神指点指点
发表于 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)


发表于 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)
您需要登录后才可以回帖 登录 | 加入

本版积分规则

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

GMT+8, 2024-10-15 09:22 , Processed in 0.077298 second(s), 20 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

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