Using Netbios (nbtstat -A or -a) through Visual Basic

Hello Experts

Is it possible to run the Netbios command thorugh VB instead of using nbtstat in DOS or typing //whatever in explorer

Thanks in advance

Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

You could shell the command in a hidden window and redirect output to a text file,then open the textfile to get the data.

here is an example using a command button and a listbox:

Private Declare Function OpenProcess Lib "Kernel32" (ByVal dwDesiredAccess As Long, ByVal bInheritHandle As Long, ByVal dwProcessId As Long) As Long
Private Declare Function GetExitCodeProcess Lib "Kernel32" (ByVal hProcess As Long, lpExitCode As Long) As Long
Private Declare Sub Sleep Lib "Kernel32" (ByVal dwMilliseconds As Long)

Private Sub ShellWait(ByVal JobToDo As String)
Dim hProcess As Long, RetVal As Long
    hProcess = OpenProcess(&H400, False, Shell(JobToDo, vbHide))
        GetExitCodeProcess hProcess, RetVal
        DoEvents: Sleep 100
    Loop While RetVal = &H103
End Sub

Private Sub Command1_Click()
Dim Ln As String, IpAddress As String
Dim ff As Integer
' change ip address to the ip or machine name to check
IpAddress = ""
' shell and wait for command to complete.
ShellWait Environ("Comspec") & " /c nbtstat -A " & IpAddress & " > TmpUsr.tmp"
ff = FreeFile
Open "TmpUsr.tmp" For Input As #ff
Do Until EOF(ff)
Line Input #ff, Ln
If Trim$(Ln) <> "" Then
    List1.AddItem Ln
End If
Close #ff
Kill "TmpUsr.tmp"
End Sub
Here's an API example that gets MAC Address:
rocket24Author Commented:
Thanks thats intresting code but what I meant is that my program would have a text box and a command button.

The text box would be where the IP address is entered and the command button would connect to it (if the shares were active) and open it in explorer like on a network when you open explorer and type "\\" or something in the address bar and then the shares are displayed.

Thanks again

Big Business Goals? Which KPIs Will Help You

The most successful MSPs rely on metrics – known as key performance indicators (KPIs) – for making informed decisions that help their businesses thrive, rather than just survive. This eBook provides an overview of the most important KPIs used by top MSPs.

nbtstat is for checking NetBios session information not for veiwing what shares are present on a computer. Why re-invent the wheel here. If you want to see what shares are available just right click on my computer choose manage and then connect to the other computer and expand the shared folders and look at shares.
Have you tried using ShellExecute API:

Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long

Private Sub Command1_Click()
Call ShellExecute(hwnd, "Open", ("\\"), "", "", 1)
End Sub

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
rocket24Author Commented:
Thanks vinnyd79 although your code didn't work until I replaced the API with this one.

Private Declare Function ShellExecute _
    Lib "shell32.dll" Alias "ShellExecuteA" ( _
    ByVal hwnd As Long, _
    ByVal lpOperation As String, _
    ByVal lpFile As String, _
    ByVal lpParameters As String, _
    ByVal lpDirectory As String, _
    ByVal nShowCmd As Long) As Long

Thanks everyone
rocket24Author Commented:
I do realise that that is the same code as vinnyd79 but i kept getting syntax errors before the code was neatly formatted.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.