首页 > 代码库 > au3读写hosts

au3读写hosts

#Region ;**** 参数创建于 ACNWrapper_GUI ****#AutoIt3Wrapper_icon=C:\WINDOWS\system32\SHELL32.dll|-110#EndRegion ;**** 参数创建于 ACNWrapper_GUI ****#include <Array.au3>#include <ButtonConstants.au3>#include <EditConstants.au3>#include <GUIConstantsEx.au3>#include <WindowsConstants.au3>Local $hostsdir = @SystemDir&"\drivers\etc\hosts"    $Read = FileRead($hostsdir)    $guanggao1="p2.1lo0.net"    $guanggao2="js.cnxad.com"    $array = StringRegExp($Read, ‘((?:(?:25[0-5]|2[0-4]\d|((1\d{2})|([1-9]?\d)))\.){3}(?:25[0-5]|2[0-4]\d|((1\d{2})|([1-9]?\d))))\h+‘&$guanggao1, 3)    If @error Then       FileOpen($hostsdir,1)       FileWriteLine($hostsdir,‘####屏蔽电视64MA广告开始####‘&@CRLF)       FileWriteLine($hostsdir,‘127.0.0.1 ‘&$guanggao1&@CRLF)       FileWriteLine($hostsdir,‘127.0.0.1 ‘&$guanggao2&@CRLF)       FileWriteLine($hostsdir,‘####屏蔽电视64MA广告结束####‘&@CRLF)       FileWriteLine($hostsdir,‘####屏蔽导航网址开始####‘&@CRLF)       FileWriteLine($hostsdir,‘127.0.0.1 www.hao123.com‘&@CRLF)       FileWriteLine($hostsdir,‘127.0.0.1 hao.360.cn‘&@CRLF)       FileWriteLine($hostsdir,‘####屏蔽导航网址结束####‘&@CRLF)       FileClose ($hostsdir)    EndIf