Q. How can I generate a CSV file containing a server's shares and their share permissions?

Using SrvCheck,exe, I have scripted ShrPerms.bat to generate a CSV file containing:



"jsi001","Util","NT AUTHORITY\Authenticated Users","C"
"jsi001","Util","JSIINC\Domain Admins","F"
"jsi001","PCCW","JSIINC\Domain Admins","F"
The syntax for using ShrPerms.bat is:

ShrPerms ComputerName CSVfile


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 Off
if \{%2\}==\{\} goto err1
set comp=%1
set comp=%comp:"=%
set cmp=%comp:\=%
set comp="\\%cmp%"
set cmp="%cmp%"
set csv=%2
if exist %csv% del /f /q %csv%
for /f "Tokens=*" %%a in ('srvcheck %comp%') do (
 set line=%%a
 call :parse
goto :EOF
if "%line:~0,1%" EQU "\" goto :setshr
set wrk=%line:Full Control=%
if "%line%" NEQ "%wrk%" set perm="F"&goto out
set wrk=%line:Change=%
if "%line%" NEQ "%wrk%" set perm="C"&goto out
set wrk=%line:Read=%
if "%line%" NEQ "%wrk%" set perm="R"&goto out
set perm="U"
set 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
for /f "Tokens=2 Delims=\" %%s in ('@echo %line%') do (
 set shr="%%s"
goto :EOF
@echo Syntax: ShrPerms ComputerName CSVfile

Hide comments


  • Allowed HTML tags: <em> <strong> <blockquote> <br> <p>

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.