Using the NET VIEW command, I have scripted NetViewC.bat to return all the computer names in a domain.

The syntax for using NetViewC.bat is:

for /f "Tokens=*" %%c in ('netviewc \[NetBIOS_Domain_Name\]') do (                               call :process %%c                              )                              ...                              ...                              :process                                                OR                              setlocal ENABLEDELAYEDEXPANSION                              for /f "Tokens=*" %%c in ('netviewc \[NetBIOS_Domain_Name\]') do (                               set computer=%%c                               ...                               ...                              )
Where NetBIOS_Domain_Name is an optional parameter, unless you are logged on locally.

NOTE: If the NET VIEW /DOMAIN:NetBIOS_Domain_Name command does NOT return all the computer names in the domain, see the following:

How do I diagnose and test TCP/IP or NetBIOS network connections in Windows Server 2003?

When you use the NET VIEW command to view a different computer in your domain you receive 'An extended error has occurred'?

When you connect to a Windows 2000 server using an alias, you receive 'System error 52 has occurred'?

How can I retrieve, or set, the NetBIOS over TCP/IP setting for an interface?

NetViewC.bat contains:

@echo off                              setlocal                              set dom=%1                              if defined USERDNSDOMAIN if not defined dom set dom=%USERDOMAIN%                              if not defined dom goto :err                              for /f "Tokens=1" %%c in ('net view /domain:%dom%^|Findstr /L /C:"\\"') do (                               @echo %%c                              )                              endlocal                              goto :EOF                              :err                              @echo NetViewC - a NetBIOS domain name parameter is required because you are logged on locally to %USERDOMAIN%.                              endlocal