Forum: Ruby Windows Advanced Permissions on Folders

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
F23b6c262861e95bed60448df478f5c7?d=identicon&s=25 Archie Call (acall)
on 2006-03-22 01:35
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
25e11a00a89683f7e01e425a1a6e305c?d=identicon&s=25 Wilson Bilkovich (Guest)
on 2006-03-22 02:06
(Received via mailing list)
On 3/21/06, Archie Call <archcall@gmail.com> 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:
http://msdn.microsoft.com/msdnmag/issues/04/11/Acc...
0b561a629b87f0bbf71b45ee5a48febb?d=identicon&s=25 Dave Burt (Guest)
on 2006-03-22 08:09
(Received via mailing list)
Archie Call 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
* Rubyforge project: http://rubyforge.org/projects/win32utils/
* download: http://rubyforge.org/frs/?group_id=85&release_id=1918

Cheers,
Dave
This topic is locked and can not be replied to.