' ************************************************************** ' Класс Ping для пакета VBS ' Используется для проверки наличия сетевого соединения с компьютером ' Возвращает IP адрес, если команда ping потеряла менее 100% пакетов ' ************************************************************** ' © 2005 Васильев Григорий ' Modified date: 27.09.2009 by Nic ' ************************************************************** Function Ping(strHost, ByteCount, TimeOut) On Error Resume Next With fso Do strTempFile = .BuildPath(.GetSpecialFolder(2), .GetTempName) Loop While .FileExists(strTempFile) strCmdLine = .BuildPath(.GetSpecialFolder(1), "ping.exe") _ & " -l " & ByteCount _ & " -w " & TimeOut _ & " -n 1 " & strHost & " > " & strTempFile End With shell.Run "%comspec% /c " & strCmdLine, 0, True Set objTS = fso.OpenTextFile(strTempFile, 1) Text = objTS.ReadAll objTS.Close fso.DeleteFile strTempFile With re .Pattern = "\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}" .IgnoreCase = True .Global = False Set Matches = .Execute(Text) End With If UBound(Matches) > 0 Then IP = Matches(0).Value re.Pattern = "\(100%" If re.Test(Text) Then IP = "" Ping = IP End Function