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


 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

 

本文作者:



相关阅读:
CSS 快速提升设计可读性和维护性
ASP 高亮显示不区分大小写的关键字
BBS(php & mysql)完整版(五)
asp.net 页面回车触发button按钮事件
js 自定义的联动下拉框
PHP开发规范手册之PHP代码规范详解
设定sql server定期自动备份数据库
JavaScript 设计模式 安全沙箱模式
Asp.net(c#)数据库操作类
ASP的一些自定义函数整理
Apache+PHP+Zend的安装及配置
ASP获取ACCESS数据库表名及结构的代码
磁盘管理--pwd
ASP.NET缓存:方法分析和实践示例
快速导航

Copyright © 2016 phpStudy |