# Have Batch File Create Log of Output



## briang

I know this is simple. Can someone throw me a bone here. I googled it up and came out empty. I tried using Write, but that didnt work. Thanks in advance.

-Brian Gonzalez
[email protected]


----------



## Rockn

A little more info please. What log files are you trying to output and to what?


----------



## briang

Rockn said:


> A little more info please. What log files are you trying to output and to what?


sure sorry about that. I want to use the attached batch file, which tells what users are sitting at what station, and i want to add a date and time in the batch and then have it all output to a txt file, so i can look back and see what users where sitting where, because in the environment i support there are over 100 users sitting in diff. seats everyday. Thanks.

-Brian Gonzalez
[email protected]


----------



## Squashman

Is this on a Windows Domain with Active Directory. This can probably be solved alot easier if it is. You can just setup a group policy to Audit all logon events.

Or

You could also use NBTscan on your computer to find out who is logged onto every computer on your network. This is a pretty awesome utility. I think you will like it better than using Net View and NBTstat.
http://www.inetcat.org/software/nbtscan.html



> NBTscan is a program for scanning IP networks for NetBIOS name information. It sends NetBIOS status query to each address in supplied range and lists received information in human readable form. For each responded host it lists IP address, NetBIOS computer name, logged-in user name and MAC address.


NBTdump is another good program as well.

To answer your original question. To direct output to a file you just use the greater-than symbol to write to a file and two greater-than symbols to append to a file.



Code:


C:\nbtscan>echo write this text to a file > filename.txt

C:\nbtscan>type filename.txt
write this text to a file

C:\nbtscan>echo append this text to a file >> filename.txt

C:\nbtscan>type filename.txt
write this text to a file
append this text to a file

C:\nbtscan>


----------



## briang

Have you tested this application in a Windows XP environment?. All of our machines do not have the NetBios protocol installed. Is there another way to do that?. thanks


----------



## Squashman

You are confusing Netbios with Netbeui. 

I believe Netbios over TCP/IP is turned on by default on all Windows Operating Systems.

I have two Windows XP desktops and one 2000. It works just fine on my home network. I have also used it at work and at school.


----------



## briang

LwdSquashman said:


> You are confusing Netbios with Netbeui.
> 
> I believe Netbios over TCP/IP is turned on by default on all Windows Operating Systems.
> 
> I have two Windows XP desktops and one 2000. It works just fine on my home network. I have also used it at work and at school.


O ok. Thank you very much. I will look further into the syntax on the app, because my first attempt was sad at best..lol. Thank you for pointing me in the right direction.

-Brian Gonzalez
[email protected]


----------



## Squashman

nbstat network ip address/subnet

nbtscan 192.168.0.0/24

That will scan all ip addresses from 192.168.0.1 to 192.168.0.255

Right now I only have two Windows machines active on my network. My laptop is turned on but nobody is logged into it so it shows the computer name where it is suppose to show who is logged on.



Code:


C:\nbtscan>nbtscan 192.168.0.0/24
Doing NBT name scan for addresses from 192.168.0.0/24

IP address       NetBIOS Name     Server    User             MAC address
------------------------------------------------------------------------------
192.168.0.0     Sendto failed: Cannot assign requested address
192.168.0.1     Recvfrom failed: Connection reset by peer
192.168.0.109    LFE_MOBL_SQUASH  <server>  LFE_MOBL_SQUASH  00-06-04-9e-69-18
192.168.0.119    SQUASH           <server>  SQUASHMAN        10-32-ba-c0-52-32

C:\nbtscan>

In this example I am logged onto Computer SQUASH and logged in as SQUASHMAN. You can see on my laptop that nobody is logged onto it because the computer name is the same as the username.


----------



## briang

nbtscan not working.
I tried to perform a scan for all machines from 10.3.10.1 to 10.3.10.30 and i got this response?. thanks again in advance for the hel.

C:\>nbtscan 10.3.10.1/30
Doing NBT name scan for addresses from 10.3.10.1/30

IP address NetBIOS Name Server User MAC address
------------------------------------------------------------------------------
10.3.10.1 Recvfrom failed: Connection reset by peer
10.3.10.3 Recvfrom failed: Connection reset by peer


----------



## Squashman

briang said:


> nbtscan not working.
> I tried to perform a scan for all machines from 10.3.10.1 to 10.3.10.30 and i got this response?. thanks again in advance for the hel.
> 
> C:\>nbtscan 10.3.10.1/30
> Doing NBT name scan for addresses from 10.3.10.1/30
> 
> IP address NetBIOS Name Server User MAC address
> ------------------------------------------------------------------------------
> 10.3.10.1 Recvfrom failed: Connection reset by peer
> 10.3.10.3 Recvfrom failed: Connection reset by peer


You are doing it wrong. If you want to scan all addresses between 10.3.10.1 to 10.3.10.30 you would do it like this.


Code:


nbtscan 10.3.10.1-30

I have a class c network so it looks like this.


Code:


C:\nbtscan>nbtscan 192.168.0.100-253
Doing NBT name scan for addresses from 192.168.0.100-253

IP address       NetBIOS Name     Server    User             MAC address
------------------------------------------------------------------------------
192.168.0.109    LFE_MOBL_SQUASH  <server>  ADMINISTRATOR    00-08-02-9d-69-18
192.168.0.119    SQUASH           <server>  SQUASHMAN        12-34-ba-c0-52-32

C:\nbtscan>

The */24* is for the subnet. Not how many IP addresses you want to scan.

Just type nbtscan at the dos prompt. It will show you some examples and what switches you can use to get different output.


----------

