Sign up for the ITPro Today newsletter
Stay on top of the IT universe with commentary, news analysis, how-to's, and tips delivered to your inbox daily.
October 3, 2001
I have scripted FindAcct.bat, which parses the output of CACLS for the account or group you specify.
The usage syntax is:
FindAcct StartPath Account ReportFile
where:
StartPath | The starting folder or root. Examples:C: or "C:Documents and Settings". |
---|---|
Account | The account or group. Examples:Administrators or "JSIINCJerry". |
ReportFile | The full path to the file that contains the report. Example: "%TEMP%FindAcct.txt". |
FindAcct.bat contains:
@echo offsetlocalIf {%1}
<h1><a name="_goto_syntax_If_2_" id="_goto_syntax_If_2_">{} goto syntaxIf {%2}</a></h1>
{} goto syntaxIf {%3}=={} goto syntaxset from=%1set from=%from:"=%set group=%2set group=%group:"=%set report=%3if exist %report% del /f /q %report%call :docacls %1for /f "Tokens=*" %%i in ('dir "%from%" /B /AD /S') do call :docacls "%%i"endlocalgoto :EOF:syntax@echo Syntax: FindAcct StartPath Account ReportFileendlocalgoto :EOF:docaclsset folder=%1set folder=%folder:"=%for /f "Tokens=*" %%j in ('CACLS "%folder%"') do call :fndgrp "%%j"goto :EOF:fndgrpset work=%1set work=%work:"=%set perm=%work%for /f "Tokens=*" %%k in ('@echo %%work:%group%^=%%') do set work="%%k"if %work% EQU "%perm%" goto :EOFset perm=%perm% #set perm=%perm:~0,50%@echo %perm% "%folder%">>%report%
You May Also Like