Sergey_AV
Silver Member | Редактировать | Профиль | Сообщение | Цитировать | Сообщить модератору '*************************************************************************************************** Option Explicit '*************************************************************************************************** Main '*************************************************************************************************** Private Function IsValidObject(ByVal o) IsValidObject = False If IsObject(o) Then If Not o Is Nothing Then IsValidObject = True End Function '--------------------------------------------------------------------------------------------------- Private Sub ReleaseObject(ByRef o) If IsValidObject(o) Then Set o = Nothing o = Empty End Sub '*************************************************************************************************** Private Function CheckPing(ByVal url) Dim oShell, oEnv, oFSO, oFile, oTextStream, sCmd, oExec, txt, txt1, n Dim logFileName logFileName="c:\pingLog.txt" Set oShell = CreateObject("WScript.Shell") Set oEnv = oShell.Environment("Process") sCmd = oEnv("COMSPEC") ReleaseObject oEnv Set oExec = oShell.Exec(sCmd & " /C ping.exe " & url & " 2>&1") ReleaseObject oShell If Not IsValidObject(oExec) Then CheckPing=False Exit Function End If n=70 Do While (oExec.Status = 0) AND (n>0) WScript.Sleep 200 n = n - 1 Loop If oExec.Status = 0 Then oExec.Terminate ReleaseObject oExec CheckPing = False Exit Function End If txt = oExec.StdOut.ReadAll ReleaseObject oExec txt1 = Replace(txt, "TTL", "AAA") CheckPing = Not (txt = txt1) If Not CheckPing Then Set oFSO = CreateObject("Scripting.FileSystemObject") On Error Resume Next Set oFile = oFSO.GetFile(logFileName) On Error Goto 0 If IsValidObject(oFile) Then Set oTextStream = oFile.OpenAsTextStream(8) Else Set oTextStream = oFSO.CreateTextFile(logFileName, True) End If ReleaseObject oFSO oTextStream.WriteLine "*************************************************" oTextStream.Write txt ReleaseObject oFile ReleaseObject oTextStream End If End Function '*************************************************************************************************** Private Sub CheckOnce Dim oShell If Not CheckPing("forum.ru-board.com") Then WScript.Sleep 50000 If Not CheckPing("google.ru") Then WScript.Sleep 90000 If Not CheckPing("forum.ru-board.com") Then WScript.Sleep 50000 If Not CheckPing("google.ru") Then 'WScript.echo "Ping Fail" Set oShell = CreateObject("WScript.Shell") oShell.Run """приложение 1.exe""", 2, true ReleaseObject oShell End If End If End If End If End Sub '*************************************************************************************************** Private Sub Main() Dim oShell Set oShell = CreateObject("WScript.Shell") oShell.Run """приложение.exe 2.exe""", 2, true ReleaseObject oShell Do While True CheckOnce WScript.Sleep 3600000 WScript.Sleep 10000 Loop End Sub '*************************************************************************************************** | Всего записей: 2336 | Зарегистр. 05-03-2002 | Отправлено: 13:15 29-09-2009 | Исправлено: Sergey_AV, 13:15 29-09-2009 |
|