Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
Hi, i am a novice for writing batch files, i would like to know how to write .bat file so that it can run the command "nbtstat -a 192.168.0.1" (for example)and store it in to some result text file.
I got the following .bat file from my friend which is used for pining many ip's from the text file and store the result in another text file. Not sure if i can apply to for nbtstat command:
@echo on
for /f "tokens=*" %%I in (C:\ping\works.txt) do call :pinger %%I
goto :eof
:pinger
---------- >> result.txt
echo %time% >> result.txt
ping -n 1 %1 >> result.txtThanks a lot !

Hi,
Not sure about nbtstat because I don't have a network.
But the bat syntax looks OK. EXCEPT that I would add
goto :eof
after the ping line to "end the subroutine".
AND your first line needs to be:
@echo OFF
Probably neither will effect the usefulness of this bat, but may seriously impact others.
HTH
=====================================
If at first you don't succeed, you're about average.M2Go

Yep i tried it but it still running erros in the terminal... im not even sure if ntbstat -a can even be applied with this code

Try running individual nbtstat command at the prompt to get the command right. Then try to natch it.
What is in your:
C:\ping\works.txt
?
=====================================
If at first you don't succeed, you're about average.M2Go

Okay it works fine for me now, just renamed nbtstat.bat file to test.bat and then apply the following command .....now it works.
@echo on
for /f "tokens=*" %%I in (C:\ping\nbtstat\works.txt) do call :pinger %%I
goto :eof
:pinger
---------- >> result.txt
echo %time% >> result.txt
nbtstat -a %1 >> result.txt
Thanks a lot !

Yeah, If you name a BAT to the same name as an EXE COM or internal command, things can get very weird.
=====================================
If at first you don't succeed, you're about average.M2Go

![]() |
![]() |
![]() |

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