Hey,
I have two processes,
test.pl and
proc.pl.
test.pl runs with elevated rights (as administrator), the other runs as a restricted normal user. They have a common folder in which
test.pl creates a file name
lock.tmp. Then it will have such permissions that
proc.pl won't be able to read it, let alone its attributes or modification time. The last one is the most important, I would like to get the modification time (for this purpose I use GetFileTime from Win32API::File::Time) from
proc.pl. A great solution to this problem is to change the owner of
lock.tmp to the virtual user
Everyone and grant full access. This needs to be done from perl, I can't and won't use command line tools. What I found is Win32::Perms. I wrote a few lines using this package to remove all permissions first.
use Win32::Perms;
my $file = new Win32::Perms('lock.tmp');
$file->Remove(-1);
$file->Set();
$file->Close();
This is the point I stuck. I would like to add the special user
Everyone and grant full access. Sometimes
$dir->Add( { Account => NULL, Mask => FULL );
does it, sometimes not, but I think this last piece of code is nasty.
Everyone is tricky because its name is something else on different translations of Windows. My script should run even on these as well. There should be some special and unique ID for Everyone in Windows, because if I bring a file within an archive, from a translated Windows to a non-translated one, it's still
Everyone (however it's written in the language that Windows was translated to). Is there any way of setting the owner of a file/directory without specifying the owner's name?
I don't insist on Win32::Perms. If there's another neat Win32 package that could have the job done, also great for me. Nevertheless it would be also a good solution if I could force perl to create every file and folder with this permission mask (similarly to umask in UNIX).
Thanks in advance
stringZ
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.