利用VBS发送邮件 挑选速度快的肉鸡做VPN 的vbs代码 |
一.挑选速度快的肉鸡做VPN 。 复制代码 代码如下: On Error Resume Next code by NetPatch Set arg=Wscript.Arguments 声明外部参数 If Arg.count=0 then Wscript.quit 若没有参数则退出脚本 Num=0 SzBuf = InputBox( "请输入要找的Ping时间值:", "输入", "200" ) 调用弹出消息输入框来获取要查找的时间 Set Fso=CreateObject("Scripting.FileSystemObject") 声明FSO组件 Set Gofile=Fso.OpenTextFile(Arg(0),1,False,-2) 打开拖进来的文件 Do While Gofile.Atendofline <> True Ip=Gofile.Readline 读取一行 Set oShell = WScript.CreateObject("WScript.Shell") 声明WSH组件 Set oExec = oShell.Exec("ping -n 1 "&Ip&"") 执行PING命令,然后把结果附值到oExec Set File=fso.OpenTextFile(arg(0)&".txt",8,True) Do While Not oExec.StdOut.AtEndOfStream strOut = oExec.StdOut.ReadLine() If oExec.StdOut.line>4 then exit do 用循环读取指定行数 Loop If Cint(GET_Time(StrOut)) < Cint(SzBuf) Then File.Writeline Ip&chr(9)&"Ping时间值为:"&GET_Time(StrOut)&"秒" 找到小于指定时间的机器,并写入新建立的文本 Num=Num+1 找到后,记数(后面统计用) End if Loop File.Close Gofile.Close Set Fso=Nothing if num = 0 then wscript.echo "郁闷!一个也没找到@_@" else wscript.echo "恭喜!找到"&num&"个" end if 用正则查找指定的PING时间值 Function GET_Time(ss) Set re = New RegExp re.Pattern = "(.+from )(\d+.\d+.\d+.\d+): bytes=32 time=(\d+)ms(.+)" re.Global = True re.IgnoreCase = True re.MultiLine = True GET_Time = re.Replace(ss,"$3") end Function 把你的肉鸡IP列表拉到这个VBS脚本上,再填入你要找的PING时间值,即可很快找出哪台肉鸡相对比较快的(当然,前提是你的肉鸡没防PING!不过话说回来,如果防PING的话,估计有防火墙一类的东西,可能也做不成VPN了 。) 。 |