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.
November 12, 2006
Using SrvCheck,exe, I have scripted ShrPerms.bat to generate a CSV file containing:
"ComputerName","ShareName","UserOrGroup","ForCorRorU"
like:
"jsi001","Util","NT AUTHORITYAuthenticated Users","C""jsi001","Util","JSIINCDomain Admins","F""jsi001","PCCW","Everyone","R""jsi001","PCCW","JSIINCDomain Admins","F"
The syntax for using ShrPerms.bat is:
ShrPerms ComputerName CSVfile
Where:
ComputerName is the NetBIOS computer name of the 'server'.CSVfile is the fully qualified file name of the CSV to be generated.
ShrPerms.bat contains:
@echo Offsetlocalif {%2}=={} goto err1setlocalset comp=%1set comp=%comp:"=%set cmp=%comp:=%set comp="\%cmp%"set cmp="%cmp%"set csv=%2if exist %csv% del /f /q %csv%for /f "Tokens=*" %%a in ('srvcheck %comp%') do ( set line=%%a call :parse)endlocalgoto :EOF:parseif "%line:~0,1%" EQU "" goto :setshrset wrk=%line:Full Control=%if "%line%" NEQ "%wrk%" set perm="F"&goto outset wrk=%line:Change=%if "%line%" NEQ "%wrk%" set perm="C"&goto outset wrk=%line:Read=%if "%line%" NEQ "%wrk%" set perm="R"&goto outset perm="U":outset obj=%wrk: =#%for /f "Tokens=1 Delims=#" %%b in ('@echo %obj%') do ( set obj="%%b")set obj=%obj: "="%@echo %cmp%,%shr%,%obj%,%perm%>>%csv%goto :EOF:setshrfor /f "Tokens=2 Delims=" %%s in ('@echo %line%') do ( set shr="%%s")goto :EOF:err1@echo Syntax: ShrPerms ComputerName CSVfileendlocal
You May Also Like