Jump to content

StdOut for nbtstat command?


Recommended Posts

Hi. I am trying to write a function to report a computer name by way of it's IP Address. This can be done in windows at the command prompt using the command NBTSTAT -A <IP Address>. I don't understand how to use standard output to get the output of that command into some AutoIT variables. Can someone show me how to read this command's output?

Link to comment
Share on other sites

Modified from the help file on StdoutRead() :

#include <Constants.au3>

$nbtstat = Run(@ComSpec & " /c " & 'NBTSTAT -A 127.0.0.1', @SystemDir, @SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD)
$out = ''

While 1
    $line = StdoutRead($nbtstat)
    If @error Then ExitLoop
    $out &= $line & @CRLF
Wend
MsgBox(0, "test", $out )
Edited by danwilli
Link to comment
Share on other sites

Modified from the help file on StdoutRead() :

#include <Constants.au3>

$nbtstat = Run(@ComSpec & " /c " & 'NBTSTAT -A 127.0.0.1', @SystemDir, @SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD)
$out = ''

While 1
    $line = StdoutRead($nbtstat)
    If @error Then ExitLoop
    $out &= $line & @CRLF
Wend
MsgBox(0, "test", $out )
Do you get a weird MsgBox when you run this?

I get one with just the Title bar part and the "X" to close it.

Edited by herewasplato

[size="1"][font="Arial"].[u].[/u][/font][/size]

Link to comment
Share on other sites

  • 4 weeks later...

Do you get a weird MsgBox when you run this?

I get one with just the Title bar part and the "X" to close it.

I didn't before, but now I do... It appears that something changed in StdoutRead().

It was sending too much data to the MsgBox, so it made the weird one you saw.

Had to add <If $line <> ''> to stop all the white space from being put into the string.

This works in latest version:

#include <Constants.au3>

$nbtstat = Run(@ComSpec & " /c " & 'NBTSTAT -A 127.0.0.1', @SystemDir, @SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD)
$out = ''

While 1
    $line = StdoutRead($nbtstat)
    If @error Then ExitLoop
    If $line <> '' Then $out &= $line & @CRLF
Wend
MsgBox(0, "test", $out )
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...