标签:add exce start rgs 就是 int output click lse
Sub nbtstat(ByVal ip As String)
Dim strRst, strRst1, strRst2, strRst3 As String
Dim n1, n2, n3 As Integer
Try
Dim p As New Process() ‘用Process就可以
p.StartInfo.FileName = "cmd.exe"
p.StartInfo.UseShellExecute = False
p.StartInfo.RedirectStandardInput = True
p.StartInfo.RedirectStandardOutput = True
p.StartInfo.RedirectStandardError = True
p.StartInfo.CreateNoWindow = True
p.Start()
Application.DoEvents()
p.StandardInput.WriteLine("cmd /c C:\\Windows\\sysnative\\nbtstat.exe -a" & ip) ‘这个就是cmd命令,64位電腦用
p.StandardInput.WriteLine("Exit") ‘这个是退出语句
strRst = p.StandardOutput.ReadToEnd() ‘执行完语句后取得显示内容.
p.Close()
Catch ex As Exception
End Try
‘之后就是你自己的代码了...
If InStrRev(strRst, "找不到主机") > 0 Then
strRst1 = "找不到主机"
End If
If Not strRst1 = "找不到主机" Then
n1 = InStrRev(strRst, "0> 唯一") - 22
strRst1 = Mid(strRst, n1, 20)
strRst1 = strRst1.Replace(" ", "") ‘Host Name
n2 = InStrRev(strRst, "0> 组") - 22
strRst2 = Mid(strRst, n2, 20)
strRst2 = strRst2.Replace(" ", "") ‘WorkGroup Name
n3 = InStrRev(strRst, "MAC") + 8
strRst3 = Mid(strRst, n3, 20)
strRst3 = strRst3.Replace(" ", "") ‘MAC Address
End If
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
nbtstat(" 10.0.2.1")
End Sub
vb.net 使用ip查詢(Host Name)(WorkGroup Name)(MAC Address)-運用cmd及nbtstat命令
标签:add exce start rgs 就是 int output click lse
原文地址:https://www.cnblogs.com/leme-chen/p/9322560.html