Hi
pgduke65, you'll discover how shaggy is working in that OS..
i'm not a guru of windows nor a Perl master but i'have now a 12+ years experience administrering winz osses with Perl and my suggestion too is to rely on native commands (as
BrowserUk already said) to interact with the system.
I started my early attempts using Admin::Misc and after some years it become no more installable-usable: i had to rewrite a big part of many program to switch to a Perl after 5.8. (see also
this node)
Below i present you an aged but still used (by me) piece of code that set permission on a folder. Even if is rough it highlights some problem you also can meet. The ch_acl sub does not call the icacls command directly, instead it passes its args to a test_my_command sub that cycle trying the command until it get back a correct value. This was because the user was created (in a domain) and immediatly used in the permission of a folder; early code sometimes failed because 'No mapping..' was found between the username and a SID..
sub ch_acl{
my ($root, $user, $diritto)=@_; ##$diritto means $right
my $ok = undef;
$diritto = 'M' unless defined $diritto;
die "What you are trying to do?" unless $diritto =~/[R|W|C|F|M
+]/i;
print "********************************icacls $root /T /grant:r $use
+r:(OI)(CI)$diritto\n\n";
while (!$ok){$ok = &test_my_command($root, $user, $diritto)}
print "\n*** PERMISSION SET CORRECTLY\n";
}
sub test_my_command{
my ($root, $user, $diritto)=@_;
my $output = `icacls $root /T /grant:r $user:(OI)(CI)$diritto 2>&1
+`;
if ($output =~ /No mapping/si){print "No mapping..\n";sleep 1;retu
+rn undef}
else{print "OK\n$output";return 1;}
}
Note also the 2>&1 at the end of the command: it is very important because cmd.exe mix OUT and ERR (and their order iirc). If you do not want to get old in the ms docs site consider using
this useful site where you can find
icacls examples too. You have to learn also the inheritance system of permission specified by the
(OI)(CI) part of the above example.
Another very useful knoweldge to have to survive in such jungle is to have very clear understanding of the latest trap they lied to force us to follow their path or die: filesystem redirection. It is very important especially if you use Perl 32bit on a 64 bit OS. I have yet described
hereHtH
L*
There are no rules, there are no thumbs..
Reinvent the wheel, then learn The Wheel; may be one day you reinvent one of THE WHEELS.
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.