服务器之家

服务器之家 > 正文

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

时间:2020-07-22 13:45     来源/作者:VBS教程网
  1. Option Explicit   
  2. Dim sourcefile,ipaddress,objargs  
  3.  
  4. const destfile="tempfile"  
  5. Const ForWriting = 2  
  6.  
  7. Dim Text  
  8. Dim fso,objNet,ServiceObj  
  9. Dim txtStream, txtStreamOut   
  10.  
  11. Set objArgs = WScript.Arguments   
  12. If objArgs.Count = 2 Then   
  13. sourcefile=objArgs(0)  
  14. ipaddress=objargs(1)  
  15. Else  
  16. wscript.echo "Parameter Error"+ vbcrlf  
  17. wscript.Echo "USAGE:KillLog.vbs LogFileName YourIP."  
  18. wscript.Quit 1  
  19. End If  
  20.  
  21.  
  22. Set fso = CreateObject("Scripting.FileSystemObject")  
  23. if fso.FileExists (sourcefile) then  
  24. Set objNet = WScript.CreateObject( "WScript.Network" )  
  25. Set ServiceObj = GetObject("WinNT://" & objNet.ComputerName & "/w3svc")  
  26. Set objNet=nothing  
  27. ServiceObj.stop  
  28. wscript.sleep 6000  
  29. Set txtStream = fso.OpenTextFile(sourcefile)   
  30. Set txtStreamOut = fso.OpenTextFile(destfile, ForWriting, True)  
  31. Do While Not (txtStream.atEndOfStream)   
  32. Text = txtStream.ReadLine   
  33. if instr(Text,ipaddress)=0 then  
  34. txtStreamOut.WriteLine Text   
  35. end if  
  36. Loop  
  37.  
  38. Set txtStream = Nothing   
  39. Set txtStreamOut = Nothing  
  40.  
  41. WScript.Echo "The log file-- " & sourcefile &" has cleaned your IP!"  
  42. Else  
  43. WScript.Echo "The Log file-- " & sourcefile & " has not found!"  
  44. Wscript.quit  
  45. End If  
  46. fso.Copyfile destfile, sourcefile  
  47. fso.deletefile destfile  
  48. Set fso=Nothing  
  49. ServiceObj.start  
  50. Set ServiceObj = Nothing  
标签:

相关文章

热门资讯

2020微信伤感网名听哭了 让对方看到心疼的伤感网名大全
2020微信伤感网名听哭了 让对方看到心疼的伤感网名大全 2019-12-26
歪歪漫画vip账号共享2020_yy漫画免费账号密码共享
歪歪漫画vip账号共享2020_yy漫画免费账号密码共享 2020-04-07
男生常说24816是什么意思?女生说13579是什么意思?
男生常说24816是什么意思?女生说13579是什么意思? 2019-09-17
沙雕群名称大全2019精选 今年最火的微信群名沙雕有创意
沙雕群名称大全2019精选 今年最火的微信群名沙雕有创意 2019-07-07
玄元剑仙肉身有什么用 玄元剑仙肉身境界等级划分
玄元剑仙肉身有什么用 玄元剑仙肉身境界等级划分 2019-06-21
返回顶部