I'm trying to create a script that will run a few programs if I have a certain IP address. I know some C++, and did some VB years ago, but am having trouble with this VBScript. There's a syntax error w/ the if statement, but I'm not sure what it is...
set WshShell = WScript.CreateObject("WScript.Shell")
strComputer = "dunniana-ws"
set png = WshShell.exec("ping -n 1 " & strComputer)
do until png.status = 1 : wscript.sleep 10 : loop
strPing = png.stdout.readall
Select Case True
Case InStr(strPing, "Request timed out") > 1
strReply = "Request timed out"
strIpAddress = GetIP(strPing)
Case InStr(strPing, "could not find host") > 1
strReply = "Host not reachable"
strIpAddress = "N/A"
Case InStr(strPing, "Reply from") > 1
strReply = "Ping Succesful"
strIpAddress = GetIP(strPing)
End Select
If (strIPAddress >= "192.168.1.2" And strIPAddress <= "192.168.1.254") Or
(strIPAddress >= "140.106.244.2" And strIPAddress <= 140.106.244.254")
WScript.Sleep 5000
WshShell.Run "firefox.exe"
WScript.Sleep 6500
WshShell.Run "thunderbird.exe"
WScript.Sleep 1000
WshShell.Run "gaim.exe"
End If
Function GetIP(ByVal reply)
Dim P
P = Instr(reply,"[")
If P=0 Then Exit Function
reply = Mid(reply,P+1)
P = Instr(reply,"]")
If P=0 Then Exit Function
GetIP = Left(Reply, P-1)
End Function
set WshShell = WScript.CreateObject("WScript.Shell")
strComputer = "dunniana-ws"
set png = WshShell.exec("ping -n 1 " & strComputer)
do until png.status = 1 : wscript.sleep 10 : loop
strPing = png.stdout.readall
Select Case True
Case InStr(strPing, "Request timed out") > 1
strReply = "Request timed out"
strIpAddress = GetIP(strPing)
Case InStr(strPing, "could not find host") > 1
strReply = "Host not reachable"
strIpAddress = "N/A"
Case InStr(strPing, "Reply from") > 1
strReply = "Ping Succesful"
strIpAddress = GetIP(strPing)
End Select
If (strIPAddress >= "192.168.1.2" And strIPAddress <= "192.168.1.254") Or
(strIPAddress >= "140.106.244.2" And strIPAddress <= 140.106.244.254")
WScript.Sleep 5000
WshShell.Run "firefox.exe"
WScript.Sleep 6500
WshShell.Run "thunderbird.exe"
WScript.Sleep 1000
WshShell.Run "gaim.exe"
End If
Function GetIP(ByVal reply)
Dim P
P = Instr(reply,"[")
If P=0 Then Exit Function
reply = Mid(reply,P+1)
P = Instr(reply,"]")
If P=0 Then Exit Function
GetIP = Left(Reply, P-1)
End Function