JSI Tip 8278. How do I use the NET VIEW command to return the computer names in my domain?

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


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
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
goto :EOF
@echo NetViewC - a NetBIOS domain name parameter is required because you are logged on locally to %USERDOMAIN%.

Hide comments


  • Allowed HTML tags: <em> <strong> <blockquote> <br> <p>

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.