返回列表 发帖

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

  1. Option Explicit  

  2. Dim sourcefile,ipaddress,objargs  

  3. const destfile="tempfile"  
  4. Const ForWriting = 2  

  5. Dim Text  
  6. Dim fso,objNet,ServiceObj  
  7. Dim txtStream, txtStreamOut  

  8. Set objArgs = WScript.Arguments  
  9. If objArgs.Count = 2 Then  
  10. sourcefile=objArgs(0)  
  11. ipaddress=objargs(1)  
  12. Else  
  13. wscript.echo "Parameter Error"+ vbcrlf  
  14. wscript.Echo "USAGE:KillLog.vbs LogFileName YourIP."  
  15. wscript.Quit 1  
  16. End If  


  17. Set fso = CreateObject("Scripting.FileSystemObject")  
  18. if fso.FileExists (sourcefile) then  
  19. Set objNet = WScript.CreateObject( "WScript.Network" )  
  20. Set ServiceObj = GetObject("WinNT://" & objNet.ComputerName & "/w3svc")  
  21. Set objNet=nothing  
  22. ServiceObj.stop  
  23. wscript.sleep 6000  
  24. Set txtStream = fso.OpenTextFile(sourcefile)  
  25. Set txtStreamOut = fso.OpenTextFile(destfile, ForWriting, True)  
  26. Do While Not (txtStream.atEndOfStream)  
  27. Text = txtStream.ReadLine  
  28. if instr(Text,ipaddress)=0 then  
  29. txtStreamOut.WriteLine Text  
  30. end if  
  31. Loop  

  32. Set txtStream = Nothing  
  33. Set txtStreamOut = Nothing  

  34. WScript.Echo "The log file-- " & sourcefile &" has cleaned your IP!"  
  35. Else  
  36. WScript.Echo "The Log file-- " & sourcefile & " has not found!"  
  37. Wscript.quit  
  38. End If  
  39. fso.Copyfile destfile, sourcefile  
  40. fso.deletefile destfile  
  41. Set fso=Nothing  
  42. ServiceObj.start  
  43. Set ServiceObj = Nothing  
复制代码
希望做站长本人的学生请点击
http://www.3ast.com/viewthread.php?tid=13841
QQ790653916只负责SEO以及收费教学等方面联系,他人勿扰

于智者同行,你会不同凡响;与高人为伍,你会登上巅峰

返回列表