首页 电脑 电脑学堂 查看内容

清空iis log 中自己登录ip的vbs

2009-2-12 06:25 688 0

摘要:  Option Explicit Dim sourcefile,ipaddress,objargs const destfile="tempfile"Co...
关键词: sourcefile Wscript txtStream objargs Set txtStreamOut objNet fso ipaddress destfile

 Option Explicit Dim sourcefile,ipaddress,objargs const destfile="tempfile"Const ForWriting = 2 Dim TextDim fso,objNet,ServiceObjDim txtStream, txtStreamOut Set objArgs = Wscript.Arguments If objArgs.Count = 2 Then sourcefile=objArgs(0)ipaddress=objargs(1)Elsewscript.echo "Parameter Error"+ vbcrlfwscript.Echo "USAGE:KillLog.vbs LogFileName YourIP."wscript.Quit 1End If Set fso = CreateObject("scripting.FileSystemObject")if fso.FileExists (sourcefile) thenSet objNet = Wscript.CreateObject( "Wscript.Network" )Set ServiceObj = GetObject("WinNT://" & objNet.ComputerName & "/w3svc")Set objNet=nothingServiceObj.stopwscript.sleep 6000Set txtStream = fso.OpenTextFile(sourcefile) Set txtStreamOut = fso.OpenTextFile(destfile, ForWriting, True)Do While Not (txtStream.atEndOfStream) Text = txtStream.ReadLine if instr(Text,ipaddress)=0 thentxtStreamOut.WriteLine Text end ifLoop Set txtStream = Nothing Set txtStreamOut = Nothing Wscript.Echo "The log file-- " & sourcefile &" has cleaned your IP!"ElseWscript.Echo "The Log file-- " & sourcefile & " has not found!"Wscript.quitEnd Iffso.Copyfile destfile, sourcefilefso.deletefile destfileSet fso=NothingServiceObj.startSet ServiceObj = Nothing
声明:文章版权归原作者所有 部分文章转自互联网 如有侵权请联系 [邮箱地址] 删除

路过

雷人

握手

鲜花

鸡蛋

最新评论

返回顶部