IIS 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 as 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