Listing 4: MemberOfSorterandCounter.bat Set MemberOfLoc=D:\MemberOf.exe @Echo Off Set counter=0 Set domID= Set /P domID=Type the domain\UserID and press Enter: Echo. Echo Please Wait.... If Exist "%temp%\memof.txt" Del "%temp%\memof.txt" For /f "tokens=1,2,3,4 delims=[]" %%i in ('%MemberOfLoc% -q -u %domID%') Do (Set group=%%l) & (Call :Next) For /f "tokens=*" %%i in ('Sort^<%temp%\memof.txt') Do (Set group=%%i) & (Call :Next2) Echo. Echo Press any key to Exit... & Pause >NUL If Exist "%temp%\memof.txt" Del "%temp%\memof.txt" Goto :EOF :Next Echo %group%>>"%temp%\memof.txt" Goto :EOF :Next2 Set /A counter=%counter%+1 Echo %counter%) %group% Goto :EOF