- Jan 10, 2001
- 30,772
- 13
- 81
Here is the code:
For n = 3 To 9
k = CStr(n)
ComputerName = "A"
ComputerName = "RHW" + "00" + k
MsgBox "checking computer " & ComputerName
HostName = ComputerName
Dim hFile As Long, lpWSAdata As WSAdata
Dim hHostent As Hostent, AddrList As Long
Dim Address As Long, rIP As String
Dim OptInfo As IP_OPTION_INFORMATION
Dim EchoReply As IP_ECHO_REPLY
Call WSAStartup(&H101, lpWSAdata)
If GetHostByName(HostName + String(64 - Len(HostName), 0)) <> SOCKET_ERROR Then
CopyMemory hHostent.h_name, ByVal GetHostByName(HostName + String(64 - Len(HostName), 0)), Len(hHostent)
CopyMemory AddrList, ByVal hHostent.h_addr_list, 4
CopyMemory Address, ByVal AddrList, 4
End If
hFile = IcmpCreateFile()
If hFile = 0 Then
MsgBox "Unable to Create File Handle"
Exit Sub
End If
OptInfo.TTL = 255
If IcmpSendEcho(hFile, Address, String(32, "A"), 32, OptInfo, EchoReply, Len(EchoReply) + 8, 2000) Then rIP = CStr(EchoReply.Address(0)) + "." + CStr(EchoReply.Address(1)) + "." + CStr(EchoReply.Address(2)) + "." + CStr(EchoReply.Address(3)) Else: MsgBox "Timeout"
If EchoReply.Status = 0 Then
MsgBox "Reply from " + HostName + " (" + rIP + ") recieved after " + Trim$(CStr(EchoReply.RoundTripTime)) + "ms"
Else
MsgBox "Failure ..."
End If
Call IcmpCloseHandle(hFile)
Call WSACleanup
It is a hacked together program grabbed from some script sites. The goal is to go through a list of numbers corrisponding to computer names, ping the name, determine if the connection is active, and tehn grab the serial number out of the BIOS.
My issue is that one computer (7) does not exist on the network, nor has it. When the program tried to grab the IP address, it cannot find one, so it reverts to the last IP address (of 6's), pings it and finds it. Now it tries to grab the serial out of 7's BIOS but 7 doesn't exist, so it crashes. Anyone have any ideas on what to do?
For n = 3 To 9
k = CStr(n)
ComputerName = "A"
ComputerName = "RHW" + "00" + k
MsgBox "checking computer " & ComputerName
HostName = ComputerName
Dim hFile As Long, lpWSAdata As WSAdata
Dim hHostent As Hostent, AddrList As Long
Dim Address As Long, rIP As String
Dim OptInfo As IP_OPTION_INFORMATION
Dim EchoReply As IP_ECHO_REPLY
Call WSAStartup(&H101, lpWSAdata)
If GetHostByName(HostName + String(64 - Len(HostName), 0)) <> SOCKET_ERROR Then
CopyMemory hHostent.h_name, ByVal GetHostByName(HostName + String(64 - Len(HostName), 0)), Len(hHostent)
CopyMemory AddrList, ByVal hHostent.h_addr_list, 4
CopyMemory Address, ByVal AddrList, 4
End If
hFile = IcmpCreateFile()
If hFile = 0 Then
MsgBox "Unable to Create File Handle"
Exit Sub
End If
OptInfo.TTL = 255
If IcmpSendEcho(hFile, Address, String(32, "A"), 32, OptInfo, EchoReply, Len(EchoReply) + 8, 2000) Then rIP = CStr(EchoReply.Address(0)) + "." + CStr(EchoReply.Address(1)) + "." + CStr(EchoReply.Address(2)) + "." + CStr(EchoReply.Address(3)) Else: MsgBox "Timeout"
If EchoReply.Status = 0 Then
MsgBox "Reply from " + HostName + " (" + rIP + ") recieved after " + Trim$(CStr(EchoReply.RoundTripTime)) + "ms"
Else
MsgBox "Failure ..."
End If
Call IcmpCloseHandle(hFile)
Call WSACleanup
It is a hacked together program grabbed from some script sites. The goal is to go through a list of numbers corrisponding to computer names, ping the name, determine if the connection is active, and tehn grab the serial number out of the BIOS.
My issue is that one computer (7) does not exist on the network, nor has it. When the program tried to grab the IP address, it cannot find one, so it reverts to the last IP address (of 6's), pings it and finds it. Now it tries to grab the serial out of 7's BIOS but 7 doesn't exist, so it crashes. Anyone have any ideas on what to do?
