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, strResults
If (intPings = "") Then
intPings = 2
If (intTO = "") Then
intTO = 750
Const OpenAsDefault = -2
Const FailIfNotExist = 0
Const ForReading = 1
objShell.Run "%comspec% /c ping -n " & intPings & " -w " & intTO _
& " " & strHost & ">" & strTempFile, 0, True
Set objFile = objFSO.OpenTextFile(strTempFile, ForReading, _
strResults = objFile.ReadAll
Select Case InStr(strResults, "TTL=")
IsConnectible = False
IsConnectible = True