Board logo

标题: 清空iis log 中自己登录ip的vbs [打印本页]

作者: 柔肠寸断    时间: 2009-11-8 20:41     标题: 清空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  
复制代码





欢迎光临 【3.A.S.T】网络安全爱好者 (http://3ast.com./) Powered by Discuz! 7.2