Computing.Net > Forums > Programming > Writing a batch file using nbtstat

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Writing a batch file using nbtstat

Reply to Message Icon

Name: anubis
Date: May 21, 2009 at 14:24:41 Pacific
OS: Windows XP
Subcategory: Batch
Comment:

I am trying to do the following:
1. Create a batch file that will ping hosts on the network.
2. If the host is up enumerate the NETBIOS name table using nbtstat.

This has to be done using a regular batch file and not using vbs.
I have tried many ways and they all fail to enumerate the host file that I have the ping results written to. Is there a way to have nbtstat read the ip address in a text file. Here are a few of my efforts using regular batch script code and also attempting to implement nmap into the rucus.

1st attempt creates the file but nbtstat just returns the usage information:
@echo on
cls
echo "Step 1"
for /f "tokens=*" %%C in (hosts.txt) do (ping -n 1 %%C >> PingResults.txt)
echo "Step 2"
for /f "tokens=*" %%R in (PingResults.txt) do (NBTSTAT -A)

Attempt 2 using nmap in the batch file:
cls
echo "Step 1 NMAP Ping Scan"
nmap -sP <iprange/mask >> NmapPing.txt
rem IP masked for security purposes
for /L %%R in (NmapPing.txt) do (nbtstat -A %%R)
rem echo "NBTStat Enumeration"

Third attempt just tried using this with a text file that has IP addresses also tried it with hostnames and the results return ports and 1 line of enumeration. I need the entire enumeration. I hope someone can help. Thanks in advance
rem nmap -v--script nbstat.nse -iL CCBDomain.txt



Sponsored Link
Ads by Google

Response Number 1
Name: Razor2.3
Date: May 21, 2009 at 17:22:43 Pacific
Reply:

Untested:

for /f %%a in (hosts.txt) do for /f "tokens=3 delims=: " %%A in ('ping -n 1 %%a ^| find "bytes="') do nbtstat -A %%A


0
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: Writing a batch file using nbtstat

How to write in a batch file using c#? www.computing.net/answers/programming/how-to-write-in-a-batch-file-using-c/19065.html

Editing a Hex file using a Batch script www.computing.net/answers/programming/editing-a-hex-file-using-a-batch-script/19381.html

Robocopy function in a batch file www.computing.net/answers/programming/robocopy-function-in-a-batch-file/13172.html