# Windows Advanced Permissions on Folders

**URL:** <https://www.ruby-forum.com/t/windows-advanced-permissions-on-folders/55552>\
**Category:** Ruby\
**Created:** [March 22, 2006, 1:35am UTC](https://www.ruby-forum.com/t/windows-advanced-permissions-on-folders/55552 "2006-03-22T01:35:13Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![acall](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/b487fb/32.png) [@acall](https://www.ruby-forum.com/u/acall)\
**Post date:** [March 22, 2006, 1:35am UTC](https://www.ruby-forum.com/t/windows-advanced-permissions-on-folders/55552/1 "2006-03-22T01:35:13Z")

</div>

In a MS-Windows environment I know how to recurse all the folders using  
a Dir.glob statement that starts a certain level of the directory tree.

I am struggling with a way in Ruby to set the advanced permissions for  
certain folders:

Properties  
…Security  
…Advanced  
…View Edit  
…Permissions  
…13 Detailed kinds of specific permissions for the folder

There must some kind of command to set these: Is it something with  
Win32API?

I have searched hi and lo in Google with little luck?

TIA…Arch

---

<div class="post-metadata">

**Author:** ![acall](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/b487fb/32.png) [@acall](https://www.ruby-forum.com/u/acall)\
**Post date:** [March 22, 2006, 2:06am UTC](https://www.ruby-forum.com/t/windows-advanced-permissions-on-folders/55552/2 "2006-03-22T02:06:09Z")

</div>

On 3/21/06, Archie C. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> …Permissions  
> …13 Detailed kinds of specific permissions for the folder
> 
> There must some kind of command to set these: Is it something with  
> Win32API?
> 
> I have searched hi and lo in Google with little luck?
> 
> TIA…Arch

Presumably there’s an API for setting the ACLs in NTFS, but I’ve never  
used it.  
Until you figure out how to invoke that, you could just do a system()  
call out to “cacls.exe”, which will take care of it.  
Do “cacls.exe /?” to see the options.

This Google hit seems to have some useful info that could be  
interpreted into Ruby:

> **[Microsoft Learn: Build skills that open doors in your career](https://learn.microsoft.com/en-us/)**
>
> Gain technical skills through documentation and training, earn certifications and connect with the community

---

<div class="post-metadata">

**Author:** ![acall](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/b487fb/32.png) [@acall](https://www.ruby-forum.com/u/acall)\
**Post date:** [March 22, 2006, 8:09am UTC](https://www.ruby-forum.com/t/windows-advanced-permissions-on-folders/55552/3 "2006-03-22T08:09:01Z")

</div>

Archie C. wrote:

> …Permissions  
> …13 Detailed kinds of specific permissions for the folder
> 
> There must some kind of command to set these: Is it something with  
> Win32API?

You can use Win32API to access Windows API calls directly. You probably  
don’t want to.

Try win32-utils’ win32/file module. Its File.attributes(file\_name) and  
File.set\_attr(file\_name, flags) support the following attributes:  
\* archive  
\* compressed  
\* content\_indexed  
\* directory  
\* encrypted  
\* hidden  
\* normal  
\* offline  
\* read\_only  
\* reparse\_point  
\* sparse\_file  
\* system  
\* temporary\* win32/file doco:  
[http://rubyforge.org/docman/view.php/85/36/file.txt](http://rubyforge.org/docman/view.php/85/36/file.txt)

- Rubyforge project: [http://rubyforge.org/projects/win32utils/](http://rubyforge.org/projects/win32utils/)
- download: [http://rubyforge.org/frs/?group\_id=85&release\_id=1918](http://rubyforge.org/frs/?group_id=85&release_id=1918)

Cheers,  
Dave
