Using only standard commands, JSIPNExpire <Drive:>\Folder\ReportFile.txt produces the subject report.
JSIPNExpire.bat contains:
@echo off if NOT "%1""" goto begin :syntax @echo Syntax: JSIPNExpire File goto end :begin setlocal set file=%1 if exist %file% del /q %file% for /f "Skip=4 Tokens=*" %%i in ('net users') do call :parse "%%i" endlocal goto end :parse set str=#%1# set str=%str:#"=% set str=%str:"#=% if "%str%"
"The command completed successfully." goto end set substr=%str:~0,25%# set substr=%substr: =% set substr=%substr: #=% set substr=%substr:#=% if "%substr%""" goto end set /a cnt=0 for /f "Tokens=*" %%i in ('net user "%substr%"') do call :parse1 "%%i" set substr=%str:~25,25%# set substr=%substr: =% set substr=%substr: #=% set substr=%substr:#=% if "%substr%"
"" goto end set /a cnt=0 for /f "Tokens=*" %%i in ('net user "%substr%"') do call :parse1 "%%i" set substr=%str:~50,25%# set substr=%substr: =% set substr=%substr: #=% set substr=%substr:#=% if "%substr%""" goto end set /a cnt=0 for /f "Tokens=*" %%i in ('net user "%substr%"') do call :parse1 "%%i" goto end :parse1 set /a cnt=%cnt% + 1 set ustr=%1 if %ustr%
"The command completed successfully." goto end set ustr=%ustr:"=% if %cnt% EQU 2 set fullname=%ustr:~29,99% & set actv="N" if %cnt% EQU 6 goto active if %cnt% EQU 9 goto never goto end :never if %actv%"N" goto end if not "%ustr:~29,5%"
"Never" goto end set substr=%substr:"=% set substr=%substr% # set substr=%substr:~0,22% set fullname=%fullname:"=% set fullname=%fullname% # set fullname=%fullname:~0,30% @echo %substr% %fullname% >> %file% goto end :active if "%ustr:~29,2%"=="No" goto end set actv="Y" :end
0 comments
Hide comments