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                              setlocal                              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