Using RMTShare.exe, which is in the public domain, to enumerate detail share information, like
share name, path, remarks, maximum users, current number of connected users, and share permissions, AND
CACLS.EXE to enumerate the NTFS permission on the shared folder and its' sub-folders,
I have scripted RptSPX.bat.
The syntax for using RptSPX.bat is:
RptSPX ReportFile \[Except1 Except2 ... ExceptN\]
Where ReportFile is the path to the file that will contain the report, and each ExceptX is a share name that you wish to exclude. RptSPX.bat automatically excludes ADMIN$, IPC$, print$, and <Drive Letter>$.
RptSPX.bat contains:
@echo off setlocal ENABLEDELAYEDEXPANSION IF \{%1\}\{\} GOTO bad set report=%1 if exist %report% del /q %report% set except="%TEMP%\RptSPX_%RANDOM%.TMP" @echo ADMIN$>%except% @echo IPC$>>%except% @echo print$>>%except% :excl if \{%2\}
\{\} goto begin set wrk=%2 shift set wrk=%wrk:"=% @echo %wrk%>>%except% goto excl :begin set f1=Findstr /v /b /C:"The command completed successfully." set f2=findstr /v /b /L /i /g:%except% for /f "Skip=4 Tokens=1*" %%a in ('RMTSHARE \\%computername%^|%F1%^|%F2%') do ( set shr=%%a if "!shr:~1,2!#" NEQ "$#" call :share ) del /q %except% endlocal GOTO :EOF :bad @echo Usage: RptSPX ReportFile \[Except1 Except2 ... ExceptN\] @echo. endlocal :share for /f "Tokens=*" %%r in ('RMTSHARE \\%computername%\%shr%^|%F1%') do ( @echo %%r>>%report% set line=%%r if "!line:~0,5!" EQU "Path " if "!line:~19,1!" EQU ":" call :folder "!line:~18!" ) ) @echo .......................................................>>%report% goto :EOF :folder set pf=%1 set wrk=%pf:"=%# if "%wrk:~2,2%" EQU "\#" set pf=%pf:\=% cacls %pf%>>%report% for /f "Tokens=*" %%a in ('dir %pf% /ad /s /b') do ( cacls "%%a">>%report% )
0 comments
Hide comments