Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
Hi all,
Previously, I asked for a vbscript that does some certain job (I have the script of that job) after checking of connectivity with certain server and result of checking is positive, I found some script that creates a new function to check connection but I don't know how to integrate it with the job that I have. Below is what I need exactly then the script that checks connectivity.
I need the following:
1- check-1: Check connection with server-1
2- If it is possible to connect to server-1 then do Job-1
3- Whatever the result of check-1 do another check (check-2)
4- check-2: Check connection with server-2
5- If it is possible to connect to server-2 then do Job-2
6- If check-1 fails then repeat steps 1 & 2 after check-2
7- If check-2 fails then repeat steps 4 & 5 after check-1
8- The result is that there is a contiuous checking of any unconnected server, we have for example check-1 (false) then check-2 (false) then check-1 (true) then check-2 (false) then check-2 (false) then check-2 (true) then end, another example: check-1 (false) then check-2 (false) then check-1 (false) then check-2 (true) then check-1 (false) then check-1 (false) then check-1 (true) then end.
I know I'm asking for a lot but take it as a challeng, and if anyone completes this successfully then he does me a big favor.
Here is the script that I found which creates a function to check connectivity, I'm thanking who has done it and thank you all.Function IsConnectible(ByVal strHost, ByVal intPings, ByVal intTO)
' Returns True if strHost can be pinged.
' Based on a program by Alex Angelopoulos and Torgeir Bakken.
' Variables strTempFile, objShell, and objFSO have global scope
' and must be declared in the main program.
Dim objFile, strResultsIf (intPings = "") Then
intPings = 2
End If
If (intTO = "") Then
intTO = 750
End IfConst OpenAsDefault = -2
Const FailIfNotExist = 0
Const ForReading = 1objShell.Run "%comspec% /c ping -n " & intPings & " -w " & intTO _
& " " & strHost & ">" & strTempFile, 0, TrueSet objFile = objFSO.OpenTextFile(strTempFile, ForReading, _
FailIfNotExist, OpenAsDefault)
strResults = objFile.ReadAll
objFile.CloseSelect Case InStr(strResults, "TTL=")
Case 0
IsConnectible = False
Case Else
IsConnectible = True
End Select
End Function

i dont know vbs.
but here is the pseudocode:
Dim server1, server2
server1="www.google.com"
server2="www.yahoo.com"do
if isConnectible(server1,"","")=true then
'do job1
end ifif isConnectible(server2,"","")= true then
'do job2
end if
wscript.wait(5000)'sleep for 5seconds
loop while true=true 'dont know your end condition

![]() |
![]() |
![]() |

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |