Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Enumerate NTFS Folder Permissions

Posted on 2004-10-11
15
Medium Priority
?
1,344 Views
Last Modified: 2008-01-09
I have been looking everywhere and have not been able to come up with a reasonable solution for this problem.  What I am trying to do is write a program/script that will enumerate through folders and return all of the NTFS permissions for each folder.  Any ideas???
0
Comment
Question by:jfkrueger
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 6
  • 4
  • 2
15 Comments
 
LVL 96

Expert Comment

by:Lee W, MVP
ID: 12282645
Have you tried cacls?  Not Visual Basic based, but rather old DOS Batch file type thing.
0
 
LVL 96

Accepted Solution

by:
Lee W, MVP earned 500 total points
ID: 12282668
Single DOS command (utilizing two other commands) when run in the CMD.EXE command interpreter will give you the results:

for /f "tokens=1" %a in ('dir /ad /b') do @cacls %a

(If you put that in a batch file, change it so that all %a references are instead %%a (double percent)).

For more info on cacls, execute cacls /? at a command prompt.
0
 
LVL 96

Expert Comment

by:Lee W, MVP
ID: 12282672
Oh, and if you want from all directories and sub directories from the directory of execution, just add a /s to the dir part of the command -

for /f "tokens=1" %a in ('dir /ad /b /s') do @cacls %a
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 48

Assisted Solution

by:Mikal613
Mikal613 earned 500 total points
ID: 12282837
http://www.killervb.com/FileSystemLib.aspx

Included are the BackupStreamReader and BackupStreamWriter classes for reading and writing NTFS streams, including permissions, auditing and ownership objects
0
 
LVL 2

Author Comment

by:jfkrueger
ID: 12288095
leew,

That seems like a good idea and I may be able to use it, but I would need to be able specify a directory instead of running it from the current directory.  How would I go about doing this?  

Mikal613 - Thanks for the link, I haven't had time to test it out yet but will do so today and let you know how it worked.

Thanks again!
0
 
LVL 96

Expert Comment

by:Lee W, MVP
ID: 12288252
Just modify the dir command between the quotes.  For example,
for /f "tokens=1" %a in ('dir /ad /b /s c:\documents and settings') do @cacls %a
0
 
LVL 96

Expert Comment

by:Lee W, MVP
ID: 12288288
Actually, as I think about it, spaces and tabs are considered delimiters unless otherwise specified.  So it'd be best to use this instead:
for /f "tokens=1 delims=" %a in ('dir /ad /b /s' "c:\documents and settings") do @cacls "%a"

The "... delims=" effectively says no delimiters.  Also, enclose directory paths in quotes so they are read as a single directory and not multiple directories if they have spaces.
0
 
LVL 2

Author Comment

by:jfkrueger
ID: 12292188
leew,

I cannot get this to work with a directory specified, but that is OK....I can work around it.  However, I noticed that this works fine on my XP machine but when run on a Windows 2000 PC.  Is it possible that the cacls.exe command works differently on these OS's?

Thanks again...
0
 
LVL 96

Expert Comment

by:Lee W, MVP
ID: 12294350
It's possible - I don't have a 2K system handy - will tomorrow - I'll check into this.

What happens when you specify a directory?  I tested it and seemed to work fine for me, so I'd like to help resolve it...
0
 
LVL 2

Author Comment

by:jfkrueger
ID: 12299531
leew,

Using your suggestion to specify a directory: for /f "tokens=1 delims=" %a in ('dir /ad /b /s' "c:\documents and settings") do @cacls "%a"

I get the following message: "The system cannot find the file 'dir /ad /b /s' "C:\documents and settings".

Thanks again for all of your help.

0
 
LVL 48

Expert Comment

by:Mikal613
ID: 12299584
didja test mine?
0
 
LVL 2

Author Comment

by:jfkrueger
ID: 12299625
Mikal613 - I did go to the site and look around, but there is no documentation there and I would have no idea how to use it to get what I want...any suggestions?

0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses

730 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question