Jump to content

Nbtstat is not showing any output


Go to solution Solved by ioa747,

Recommended Posts

This is driving me nuts. Does anyone have experience with nbtstat? The following is from the example file except I replaced the DIR with NBTSTAT

 

#include <AutoItConstants.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
        ;Local $iPID = Run(@ComSpec & " /c DIR Example.au3", @SystemDir, @SW_HIDE, BitOR($STDERR_CHILD, $STDOUT_CHILD))
        Local $iPID = Run(@ComSpec & " /c nbtstat /a 10.0.1.11", @SystemDir, @SW_HIDE, BitOR($STDERR_CHILD, $STDOUT_CHILD))
        Local $sOutput = ""
        While 1
                $sOutput &= StdoutRead($iPID)
                If @error Then ; Exit the loop if the process closes or StdoutRead returns an error.
                        ExitLoop
                EndIf
                MsgBox($MB_SYSTEMMODAL, "Stdout Read:", $sOutput)
        WEnd

        $sOutput = ''
        While 1
                $sOutput &= StderrRead($iPID)
                If @error Then ; Exit the loop if the process closes or StderrRead returns an error.
                        ExitLoop
                EndIf
                MsgBox($MB_SYSTEMMODAL, "Stderr Read:", $sOutput)
        WEnd
EndFunc   ;==>Example

 

Quite a few examples out there for stdoutread but none have worked for nbtstat.

 

Link to comment
Share on other sites

As @ioa747 already wrote, #AutoIt3Wrapper_UseX64=y is required.
By the way: nbtstat.exe can be started directly, without using @ComSpec.

Example :

#AutoIt3Wrapper_UseX64=y
#include <AutoItConstants.au3>

Example()

Func Example()
    ; Info : 'nbtstat /?' will show help
    Local $iPID = Run('nbtstat -n', @SystemDir, @SW_HIDE, BitOR($STDERR_CHILD, $STDOUT_CHILD)) ; Instead of -n, enter the desired parameters
    Local $sOutputRead = '', $sOutputErr = ''

    While 1
        $sOutputRead &= StdoutRead($iPID)
        If @error Then ExitLoop
    WEnd

    While 1
        $sOutputErr &= StderrRead($iPID)
        If @error Then ExitLoop
    WEnd

    MsgBox(4096, "Stdout Read:", $sOutputRead)
    MsgBox(4096, "Stderr Read:", $sOutputErr)
EndFunc   ;==>Example

 

Musashi-C64.png

"In the beginning the Universe was created. This has made a lot of people very angry and been widely regarded as a bad move."

Link to comment
Share on other sites

Thanks @ioa747 and @Musashi,

Yep, tried that and still got the same results.  Turns out there are 2 problems:

1) Running the compiled exe:
Resolved by adding nbtstat -R to clear the cache and waiting a few seconds then running the command nbtstat -a xx.xx.xx.xx.

2) Running from the editor:
Not displaying anything in the body of the MsgBox. There seems to be something going on with non-compiled apps and running nbtstat.

Thanks again!

Link to comment
Share on other sites

When I tried it with your script, I didn't change anything except the IP, where I installed the IP from a TV box I have.
I ran it from the editor and it worked fine

Edit:
at first it gave me:
'nbtstat' is not recognized as an internal or external command,
operable program or batch file

which led me to put #AutoIt3Wrapper_UseX64=y at the top
and then it worked as i said

Edit:
Have you try running it, directly in the console, to see that everything goes well?

 

Edited by ioa747

I know that I know nothing

Link to comment
Share on other sites

@ioa747
Updated code slightly to see Stdout and Stderr in console.

#AutoIt3Wrapper_UseX64=y
#include <AutoItConstants.au3>
#include <MsgBoxConstants.au3>
ConsoleWrite("Started Autoit Version: " &  @AutoItVersion & @CRLF)

Example()

Func Example()
        Local $iPID = Run('nbtstat -n', @SystemDir, @SW_HIDE, BitOR($STDERR_CHILD, $STDOUT_CHILD)) ; Instead of -n, enter the desired parameters
        Local $sOutput = ""
        ConsoleWrite("=======STD OUT=========" & @CRLF)
        ConsoleWrite("Stdout Read Please Wait: " & @CRLF )
        While 1
                $sOutput &= StdoutRead($iPID)
                If @error Then ; Exit the loop if the process closes or StdoutRead returns an error.
                        ExitLoop
                EndIf
                ConsoleWrite($sOutput); & @CRLF)
        WEnd
        ConsoleWrite("=======STD ERR=========" & @CRLF)
        $sOutput = ''
        ConsoleWrite("Stderr Read Please Wait: " & @CRLF )
        While 1
                $sOutput &= StderrRead($iPID)
                If @error Then ; Exit the loop if the process closes or StderrRead returns an error.
                        ExitLoop
                EndIf
                ConsoleWrite($sOutput); & @CRLF)
        WEnd
        ConsoleWrite("=======DONE=======" & @CRLF)
EndFunc   ;==>Example

 No luck running from Scite I get:

Started Autoit Version: 3.3.16.1
=======STD OUT=========
Stdout Read Please Wait: 
=======STD ERR=========
Stderr Read Please Wait: 
=======DONE=======
>Exit code: 0

I also tried running the code from the command line prompt:
"C:\Program Files (x86)\AutoIt3\autoit3.exe" "NbtstatTest.au3"

Nothing at all displays in the command prompt.

 

Link to comment
Share on other sites

12 minutes ago, NassauSky said:

I also tried running the code from the command line prompt:
"C:\Program Files (x86)\AutoIt3\autoit3.exe" "NbtstatTest.au3"

this you have to give to command line prompt:

nbtstat /a 10.0.1.11

I know that I know nothing

Link to comment
Share on other sites

#AutoIt3Wrapper_UseX64=y
#include <WinAPIConv.au3>
#include <Constants.au3>

Local $sTxt, $sCmd, $hTimer

$sCmd = "NBTSTAT /a 192.168.1.130"
$hTimer = TimerInit()
$sTxt = RunCmd($sCmd)
ConsoleWrite("- processed in: " & Round(TimerDiff($hTimer) / 1000, 3) & " seconds " & @LF)
ConsoleWrite($sTxt & @CRLF)

;--------------------------------------------------------------------------------------------------------------------------------
Func RunCmd($sCommand)
    Local $sStream = '', $iPID = Run(@ComSpec & " /c " & $sCommand, "", @SW_HIDE, 8)
    While ProcessExists($iPID)
        $sStream &= StdoutRead($iPID)
    WEnd
    Return _WinAPI_OemToChar($sStream)
EndFunc   ;==>RunCmd
;--------------------------------------------------------------------------------------------------------------------------------


It took me 30 seconds for the result to appear, so be patient

console:

Spoiler
- processed in: 27.219 seconds 
    
VirtualBox Host-Only Network:
Node IpAddress: [192.168.56.1] Scope Id: []

    Host not found.
    
Ethernet 2:
Node IpAddress: [169.254.234.53] Scope Id: []

    Host not found.
    
Ethernet:
Node IpAddress: [192.168.1.110] Scope Id: []

           NetBIOS Remote Machine Name Table

       Name               Type         Status
    ---------------------------------------------
    TV-BOX         <00>  UNIQUE      Registered 
    TV-BOX         <03>  UNIQUE      Registered 
    TV-BOX         <20>  UNIQUE      Registered 
    ..__MSBROWSE__.<01>  GROUP       Registered 
    WORKGROUP      <00>  GROUP       Registered 
    WORKGROUP      <1D>  UNIQUE      Registered 
    WORKGROUP      <1E>  GROUP       Registered 

    MAC Address = 00-00-00-00-00-00

    
Wi-Fi:
Node IpAddress: [0.0.0.0] Scope Id: []

    Host not found.
    
vEthernet (Ethernet 2):
Node IpAddress: [172.21.64.1] Scope Id: []

    Host not found.
    
vEthernet (VirtualBox Host):
Node IpAddress: [172.24.96.1] Scope Id: []

    Host not found.
    
vEthernet (Ethernet):
Node IpAddress: [172.30.32.1] Scope Id: []

    Host not found.
    
Bluetooth Network Connection:
Node IpAddress: [0.0.0.0] Scope Id: []

    Host not found.
    
Local Area Connection* 9:
Node IpAddress: [0.0.0.0] Scope Id: []

    Host not found.
    
vEthernet (Wi-Fi):
Node IpAddress: [172.26.16.1] Scope Id: []

    Host not found.
    
Local Area Connection* 10:
Node IpAddress: [0.0.0.0] Scope Id: []

    Host not found.

 


 

Edited by ioa747

I know that I know nothing

Link to comment
Share on other sites

@ioa747 

Thanks no luck so far running it from Scite. 

After running your Autoit code: (No luck)

>"C:\Program Files (x86)\AutoIt3\SciTE\..\AutoIt3.exe" /ErrorStdOut "C:\Code\Autoit\NbtstatTest.au3"    
- processed in: 4.598 seconds 

>Exit code: 0

 

After running the DOS command in the DOS console:

C:\Code\Autoit>nbtstat /a 10.0.1.11

VirtualBox Host-Only Network:
Node IpAddress: [192.168.56.1] Scope Id: []

    Host not found.

Ethernet:
Node IpAddress: [10.0.1.2] Scope Id: []

           NetBIOS Remote Machine Name Table

       Name               Type         Status
    ---------------------------------------------
    MAINMINI  <00>  UNIQUE      Registered
    MAINMINI  <20>  UNIQUE      Registered
    WORKGROUP <00>  GROUP       Registered

    MAC Address = E7-83-88-F0-A6-FB


Bluetooth Network Connection:
Node IpAddress: [0.0.0.0] Scope Id: []

    Host not found.

Wi-Fi:
Node IpAddress: [0.0.0.0] Scope Id: []

    Host not found.

C:\Code\Autoit>

 

Strange how it works running the DOS command manually and also after I compile it but it doesn't function correctly in Scite

Edited by NassauSky
Link to comment
Share on other sites

  • Solution

Do you have SciTE4AutoIt3.exe installed? , because I don't see the extra information in your console

Edit:
and if you had set #AutoIt3Wrapper_UseX64=y
it should show
>Running:(3.3.16.1):C:\Program Files (x86)\AutoIt3\autoit3_x64.exe "D:\i\Pro\.AutoIT\_Test\000_forum-topic\211510-nbtstat-is-not-showing-any-output\Autoit1.au3"   

Edited by ioa747

I know that I know nothing

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...