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 here
HtH 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.
|