Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1904
  • Last Modified:

batch file for nbtstat -a and write results to log

Hi,
i need to find a whole bunch of UID's logged onto various machine IP's.
Rather than manually go through each one, i would like to create a bat file that will do the following:

read a source txt file for IP's
run nbtstat -a to listed IP's
write UID part from the output to a txt file.

Thanks guys.
0
-P-Henderson
Asked:
-P-Henderson
1 Solution
 
VampireofdarknessCommented:
This is as far as I got, before running out of time

@echo Off

IF EXIST ip-output.txt DEL ip-output.txt

FOR /f %%i IN (ips.txt) DO nbtstat -a %%i | find "<00>  UNIQUE">> tmp.txt
FOR /f "tokens=1,2,3,4,5 delims= " %%e IN (tmp.txt) DO echo %%e >>ip-output.txt
 
del tmp.txt

Open in new window


You need ips.txt in the same folder as the .bat, I used one IP as an example. The ip-output.txt shows "DESKTOP" (which is the name of my PC). I understand from google that the UID is meant to be <03>, but I don't have <03>. I do have <00>.

Perhaps it can help? Perhaps I'm completely off-mark.
0
 
-P-HendersonAuthor Commented:
Worked a treat, thankyou.
0

Featured Post

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now