Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.
VBScript comparing IP's
Name: smithy14975 Date: November 10, 2008 at 19:10:45 Pacific OS: XP CPU/Ram: intell 2 gig Product: Dell
Comment:
I would like to know if it is possible to compare IP's in a range with VBScript. For example, I know that if a device's IP address in between 172.31.4.1 through 172.31.4.254 it is located in the lower level of our building. I could make a device locater if I could tell a script in a if else statement to look in certain ranges. Only thing is that dots cause it to error out. I need to be able to format an IP from 172.31.4.1 to 172031004001 or maybe it's binary component of 10101100000111110000010000000001 to 10101100000111110000010011111110
How do you make a function to convert these numbers?
Name: Razor2.3 Date: November 10, 2008 at 20:08:24 Pacific
Reply:
You could convert it to a number, but VBScript doesn't do unsigned numbers, so that's just a bigger headache than most (me) want to deal with. You could also convert it into a string, but why beat around the comparison bush?
'Return: IP1 < IP2 -> -1 ' IP1 = IP2 -> 0 ' IP1 > IP2 -> 1 Function IPComp(sIP1, sIP2) Dim i, num1, num2 num1 = Split(sIP1, ".") : num2 = Split(sIP2, ".") For i = 0 To 3 If CInt(num1(i)) < CInt(num2(i)) Then IPComp = -1 Exit Function ElseIf CInt(num1(i)) > CInt(num2(i)) Then IPComp = 1 Exit Function End If Next 'i End Function
Summary: Hi, I need to have an easy to manage/understand batch file that will do this: Every morning at say 9am - Send a PING to 6 different static IP's. If the IP FAILS to respond to the PING i need it to e...
Summary: >> it doesn't like anything passed the first decimal point << Of course it doesn't. A number can only ever have one decimal point. More than one and there is something wrong. The only way to ...
Summary: I get files often that have a crc checksum in the file name but no premade sfv to check it with. So I run the file through quicksfv and open the sfv file and compare the value in the file name and the...