织梦CMS - 轻松建站从此开始!

罗索

当前位置: 主页>杂项技术>PC常识>

清理IIS LOG中自己登录ip的VBS

罗索客 发布于 2004-02-16 15:20 点击:次 
Option Explicit Dim sourcefile,ipaddress,objargs const destfile=tempfile Const ForWriting = 2 Dim Text Dim fso,objNet,ServiceObj Dim txtStream, txtStreamOut Set objArgs = WScript.Arguments If objArgs.Count = 2 Then sourcefile=objArgs(0) ipaddress=obj
TAG:

Option Explicit

Dim sourcefile,ipaddress,objargs

const destfile="tempfile"
Const ForWriting = 2

Dim Text
Dim fso,objNet,ServiceObj
Dim txtStream, txtStreamOut

Set objArgs = WScript.Arguments
If objArgs.Count = 2 Then
sourcefile=objArgs(0)
ipaddress=objargs(1)
Else
wscript.echo "Parameter Error"+ vbcrlf
wscript.Echo "USAGE:KillLog.vbs LogFileName YourIP."
wscript.Quit 1
End If


Set fso = CreateObject("Scripting.FileSystemObject")
if fso.FileExists (sourcefile) then
Set objNet = WScript.CreateObject( "WScript.Network" )
Set ServiceObj = GetObject("WinNT://" & objNet.ComputerName & "/w3svc")
Set objNet=nothing
ServiceObj.stop
wscript.sleep 6000
Set txtStream = fso.OpenTextFile(sourcefile)
Set txtStreamOut = fso.OpenTextFile(destfile, ForWriting, True)
Do While Not (txtStream.atEndOfStream)
Text = txtStream.ReadLine
if instr(Text,ipaddress)=0 then
txtStreamOut.WriteLine Text
end if
Loop

Set txtStream = Nothing
Set txtStreamOut = Nothing

WScript.Echo "The log file-- " & sourcefile &" has cleaned your IP!"
Else
WScript.Echo "The Log file-- " & sourcefile & " has not found!"
Wscript.quit
End If
fso.Copyfile destfile, sourcefile
fso.deletefile destfile
Set fso=Nothing
ServiceObj.start
Set ServiceObj = Nothing (aspsky)
本站文章除注明转载外,均为本站原创或编译欢迎任何形式的转载,但请务必注明出处,尊重他人劳动,同学习共成长。转载请注明:文章转载自:罗索实验室 [http://www.rosoo.net/a/200402/2413.html]
本文出处: 作者:aspsky
顶一下
(0)
0%
踩一下
(0)
0%
------分隔线----------------------------
发表评论
请自觉遵守互联网相关的政策法规,严禁发布色情、暴力、反动的言论。
评价:
表情:
用户名: 验证码:点击我更换图片
栏目列表
将本文分享到微信
织梦二维码生成器
推荐内容