Dim oShell Dim oExec Dim strOut Dim oRegExp Dim Matches Dim Match Dim Num Set oShell = WScript.CreateObject("WScript.Shell") Set oExec = oShell.Exec("netstat -an") Set oRegExp =new RegExp oRegExp.Pattern ="TCP[\s]+[\d\.]+:80[\s]+[\d\.]+:[\d]+[\s]+ESTABLISHED" oRegExp.IgnoreCase =True oRegExp.Global =True DoWhileNot oExec.StdOut.AtEndOfStream strOut = strOut & oExec.StdOut.ReadLine() &Chr(13) &Chr(10) Loop Set Matches = oRegExp.Execute(strOut) Num =0 ForEach Match In Matches WScript.Echo Match.Value Num = Num +1 Next WScript.Echo "合计:共"& Num &"个连接" Set Matches =Nothing Set oRegExp =Nothing Set oExec =Nothing Set oShell =Nothing