B
Broggy69
Guest
I wrote a VB.Net program that you can enter a hostname such as bld019. Then it loops through the various servers and pings them. I get the output I want, but I am trying to figure out how I can get the Subnet and Gateway as well.
Below is my code I am using
Dim ServersXYZ() As String = {"x01", "x02", "x03", "x04", "x05", "x06", "x07"}
For Each tserver As String In ServersXYZ
If tserver = "01" Then
Dim hostname As IPHostEntry = Dns.GetHostByName(txtStore.Text & tserver)
Dim ip As IPAddress() = hostname.AddressList
txt_IPList.AppendText(ip(0).ToString() & " x01 IP" & vbCrLf)
ElseIf tserver = "x02" Then
Dim hostname As IPHostEntry = Dns.GetHostByName(txtStore.Text & tserver)
Dim ip As IPAddress() = hostname.AddressList
txt_IPList.AppendText(ip(0).ToString() & " x02 IP" & vbCrLf)
ElseIf tserver = "x03" Then
Dim hostname As IPHostEntry = Dns.GetHostByName(txtStore.Text & tserver)
Dim ip As IPAddress() = hostname.AddressList
txt_IPList.AppendText(ip(0).ToString() & " x03 IP" & vbCrLf)
ElseIf tserver = "x04" Then
Dim hostname As IPHostEntry = Dns.GetHostByName(txtStore.Text & tserver)
Dim ip As IPAddress() = hostname.AddressList
txt_IPList.AppendText(ip(0).ToString() & " x04 IP" & vbCrLf)
ElseIf tserver = "x05" Then
Dim hostname As IPHostEntry = Dns.GetHostByName(txtStore.Text & tserver)
Dim ip As IPAddress() = hostname.AddressList
txt_IPList.AppendText(ip(0).ToString() & " x05 IP" & vbCrLf)
ElseIf tserver = "x06" Then
Dim hostname As IPHostEntry = Dns.GetHostByName(txtStore.Text & tserver)
Dim ip As IPAddress() = hostname.AddressList
txt_IPList.AppendText(ip(0).ToString() & " x06 IP" & vbCrLf)
ElseIf tserver = "x07" Then
Dim hostname As IPHostEntry = Dns.GetHostByName(txtStore.Text & tserver)
Dim ip As IPAddress() = hostname.AddressList
txt_IPList.AppendText(ip(0).ToString() & " x07 IP" & vbCrLf)
End If
txtStatus.AppendText("Started " & txtStore.Text & tserver & vbCrLf)
Dim ps As New Process
With ps.StartInfo
.FileName = "cmd.exe"
.Arguments = "/C ping " & txtStore.Text & tserver
.CreateNoWindow = True
.UseShellExecute = False
.RedirectStandardOutput = True
End With
ps.Start()
ps.WaitForExit()
Dim output As String = ps.StandardOutput.ReadToEnd()
txtStatus.AppendText(output & vbCrLf)
txtStatus.AppendText("Finished " & txtStore.Text & tserver & vbCrLf & vbCrLf & vbCrLf)
ps.Close()
Next
Continue reading...
Below is my code I am using
Dim ServersXYZ() As String = {"x01", "x02", "x03", "x04", "x05", "x06", "x07"}
For Each tserver As String In ServersXYZ
If tserver = "01" Then
Dim hostname As IPHostEntry = Dns.GetHostByName(txtStore.Text & tserver)
Dim ip As IPAddress() = hostname.AddressList
txt_IPList.AppendText(ip(0).ToString() & " x01 IP" & vbCrLf)
ElseIf tserver = "x02" Then
Dim hostname As IPHostEntry = Dns.GetHostByName(txtStore.Text & tserver)
Dim ip As IPAddress() = hostname.AddressList
txt_IPList.AppendText(ip(0).ToString() & " x02 IP" & vbCrLf)
ElseIf tserver = "x03" Then
Dim hostname As IPHostEntry = Dns.GetHostByName(txtStore.Text & tserver)
Dim ip As IPAddress() = hostname.AddressList
txt_IPList.AppendText(ip(0).ToString() & " x03 IP" & vbCrLf)
ElseIf tserver = "x04" Then
Dim hostname As IPHostEntry = Dns.GetHostByName(txtStore.Text & tserver)
Dim ip As IPAddress() = hostname.AddressList
txt_IPList.AppendText(ip(0).ToString() & " x04 IP" & vbCrLf)
ElseIf tserver = "x05" Then
Dim hostname As IPHostEntry = Dns.GetHostByName(txtStore.Text & tserver)
Dim ip As IPAddress() = hostname.AddressList
txt_IPList.AppendText(ip(0).ToString() & " x05 IP" & vbCrLf)
ElseIf tserver = "x06" Then
Dim hostname As IPHostEntry = Dns.GetHostByName(txtStore.Text & tserver)
Dim ip As IPAddress() = hostname.AddressList
txt_IPList.AppendText(ip(0).ToString() & " x06 IP" & vbCrLf)
ElseIf tserver = "x07" Then
Dim hostname As IPHostEntry = Dns.GetHostByName(txtStore.Text & tserver)
Dim ip As IPAddress() = hostname.AddressList
txt_IPList.AppendText(ip(0).ToString() & " x07 IP" & vbCrLf)
End If
txtStatus.AppendText("Started " & txtStore.Text & tserver & vbCrLf)
Dim ps As New Process
With ps.StartInfo
.FileName = "cmd.exe"
.Arguments = "/C ping " & txtStore.Text & tserver
.CreateNoWindow = True
.UseShellExecute = False
.RedirectStandardOutput = True
End With
ps.Start()
ps.WaitForExit()
Dim output As String = ps.StandardOutput.ReadToEnd()
txtStatus.AppendText(output & vbCrLf)
txtStatus.AppendText("Finished " & txtStore.Text & tserver & vbCrLf & vbCrLf & vbCrLf)
ps.Close()
Next
Continue reading...