JSI Tip 4490. How can I produce a list of the user logon names in my domain?

To produce a list of user logon names in your domain, you could use tip 3410, but if all you want is user logon name, with trailing spaces removed, you could use UserList.bat.

The usage syntax is:

UserList <FullPathToOutputFile>


UserList C:\TEMP\UserList.txt

UserList.bat contains:

@echo off
if \{%1\}==\{\} goto syntax
set file=%1
if exist %file% del /q %file%
for /f "Skip=4 Tokens=*" %%i in ('net user /domain^|findstr /v /c:"----"^|findstr /v /i /c:"The command completed"') do (
 set line=%%i
 call :parse
goto :EOF
@echo Syntax UserList OutputFileName
goto :EOF
set short=%name%#
set short=%short:  =%
set short=%short: #=#%
set short=%short:#=%
@echo %short%>>%file%
goto :EOF
set name=%line:~0,25%
call :strip
set name=%line:~25,25%
if not "%name%" EQU "" call :strip
set name=%line:~50,25%
if not "%name%" EQU "" call :strip

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.