Skip navigation

JSI Tip 8614. How do I retrieve all the computer names in my workgroup?


Using Browstat.exe from \SUPPORT\TOOLS\SUPTOOLS.MSI on the Windows CD-ROM, I have scripted WorkGroup.bat to return the list of computer names in your workgroup (or domain).

NOTE: In a single segment LAN, you can run Browstat.exe on any computer. If your LAN has multiple segments, run it on the browse master.

The syntax for using WorkGroup.bat is:

for /f "Tokens=*" %%c in ('workgroup') do (
 call :DoSomething %%c
)
WorkGroup.bat contains:
@echo off
for /f "Tokens=2" %%a in ('browstat VIEW Transport^|find "\Device\"') do (
 for /f "Tokens=1" %%b in ('browstat VIEW %%a^|findstr /L /B "\\"') do (
  @echo %%b
 )
)
If you always want to strip the leading \\, WorkGroup.bat would contain:
@echo off
for /f "Tokens=2" %%a in ('browstat VIEW Transport^|find "\Device\"') do (
 for /f "Skip=2 Tokens=1 Delims=\ " %%b in ('browstat VIEW %%a') do (
  call echo %%b
 )
)



Hide comments

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.
Publish