Subscribe to Windows IT Pro

 

Get Newsletters

  • Get the Latest News
  • Product Updates
  • Helpful Tricks
  • Productivity Tips

Subscribe Now!

November 11, 2004 12:00 AM

JSI Tip 8670. How can I report the NTFS folder permissions on a computer's shared folders?

Windows IT Pro
InstantDoc ID #82250
Rating: (1)


Using only standard commands, I have scripted SharedFolderPerms.bat to report the NTFS folder permissions on a computer's shared folders.

The syntax for using SharedFolderPerms.bat is:

SharedFolderPerms [/$] [/S]

Where /$ is an optional parameter that will enumerate hidden shares, and /S is an optional parameter that will report sub-folder permissions.

The report is generated in a SharedFolderPerms.log file which is created in the current folder.

NOTE: See When I query the ACL of an object with CACLS, what does the (OI), (IO), (CI), and (NP) mean?

SharedFolderPerms.bat contains:

@echo off
setlocal
if exist SharedFolderPerms.log del /q SharedFolderPerms.log
set exclude=Y
set subs=N
if /i {%1} EQU {/$} set exclude=N
if /i {%1} EQU {/S} set subs=Y
if /i {%2} EQU {/$} set exclude=N
if /i {%2} EQU {/S} set subs=Y
for /f "Tokens=1*" %%a in ('net share ^|FINDSTR /I /L /C:":"') do (
 call :parse1 %%a "%%b"
)
endlocal
goto :EOF
:parse1
set shr=%1
set fld=%2
if "%fld:~2,2%" NEQ ":\" goto :EOF
if "%exclude%" EQU "N" goto parse2
set wrk=%shr:$=%
if "%wrk%" NEQ "%shr%" goto :EOF
:parse2 
set wrk=%fld:  =%
if %wrk% EQU %fld% goto parse4
set /a pos=0
:parse3
set /a pos=%pos% + 1
call set char=%%fld:~%pos%^,2%%
if "%char%" NEQ "  " goto parse3
call set fld=%%fld:~0,%pos%%%"
set fld=%fld:\"="%
:parse4
set fld=%fld:\"="%
set /a pos=%pos% - 1
if %pos% EQU 3 call set fld=%fld:~1,2%@echo Share=%shr%,Folder=%fld%>>SharedFolderPerms.log
cacls %fld% >>SharedFolderPerms.log
if "%subs%" EQU "N" goto parse5
for /f "Tokens=*" %%f in ('dir %fld% /b /s /ad') do (
  cacls "%%f" >>SharedFolderPerms.log
)
:parse5
@echo ______________________________________>>SharedFolderPerms.log



Related Content:

ARTICLE TOOLS

Comments
    There are no comments to display. Be the first one!
You must log on before posting a comment.

Are you a new visitor? Register Here

advertisement

advertisement

White Papers

Get your Windows 7 deployment off to the right start by implementing PC lockdown. A locked-down environment is easier and cheaper to support since users are less likely to make unnecessary changes to the core system configuration - read more here!

Essential Guides

Is your iSCSI "lossy"? The reality is that most off-the-shelf Ethernet hardware deployed for iSCSI can lose packets, resulting in slow performance or application downtime. Learn how to assess your current iSCSI infrastructure and engineer an advanced iSCSI SAN infrastructure.

Web Seminars

What's the best way to keep your network safe from malware? In this web seminar, security expert Greg Shields suggests an alternative method to the traditional blacklisting approach that is common with anti-virus and anti-malware solutions.

eLearning Series

We bring the experts direct to you to share their real-world perspective and expertise. During each event, three sessions stream in real time, so you can learn, ask questions, and get solutions.
Upcoming event: Getting the Most with Exchange 2010 with Paul Robichaux

Subscribe to Windows IT Pro!

Windows is a trademark of the Microsoft group of companies. Windows IT Pro is used by Penton Media Inc. under license from owner.