VB.net using IP Enquiry (Host name) (WorkGroup name) (MAC Address)-cmd and nbtstat command

Source: Internet
Author: User

Tag:add   exce   start   rgs    is     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 () ' can be used with 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) ' This is the cmd command, 64-bit computer
P.standardinput.writeline ("Exit") ' This is the exit statement
Strrst = P.standardoutput.readtoend () ' Executes the statement and gets the display content.
P.close ()
Catch ex as Exception
End Try
' And then your own code ...
If InStrRev (Strrst, "host not Found") > 0 Then
StrRst1 = "Host not Found"
End If

If not strRst1 = "host not Found" then
N1 = InStrRev (Strrst, "0> unique")-22
StrRst1 = Mid (Strrst, N1, 20)
StrRst1 = Strrst1.replace ("", "") ' Host Name '

N2 = InStrRev (Strrst, "0> Group")-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 using IP Enquiry (Host name) (WorkGroup name) (MAC Address)-cmd and nbtstat command

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.