Skip navigation

JSI Tip 0595 - How can I build a file of all currently logged on UserNames?

Create whoison.bat in your path and call it with the full path to the file you want created:

whoison "<Drive:>\Folder\FileName.Txt"

Whoison.bat contains:

@echo off
if "%1"

"" goto syntax if exist %1 del /q %1 goto begin :syntax @echo Syntax: Whoison FileName goto end :begin for /f "Skip=4 Tokens=*" %%i in ('net session') do call :parse %1 "%%i" endlocal goto end :parse set str=%2 set str=%str:"=% if "%str%"

"The command completed successfully." goto end for /f "Tokens=*" %%i in ('@echo %%str:~23^,1%%') do set substr=%%i if "%substr%"=="ECHO is on." goto end @echo %str% >> %1 :end

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.