use Tk; use Win32; use strict 'vars'; use Win32::Perms; my $main = MainWindow->new; my (@pl) = qw/-side left -expand yes -padx 10 -pady 10 -fill both/; my $left = $main->Frame->pack(@pl); my $right = $main->Frame->pack(@pl); @pl = qw/-side top -expand yes -pady 2 -anchor w/; my $left_l1 = $left->Label(-text=>'Path')->pack(@pl); my $left_l2 = $left->Label(-text=>'Account')->pack(@pl); @pl=qw/-side top/; my $r_entry1 = $right->Entry(-width=>40, -textvariable=> \ my $path)->pack(@pl); my $r_entry2 = $right->Entry(-width=>40, -textvariable=> \ my $acc)->pack(@pl); @pl = qw/-side bottom -padx 5 -pady 5/; my $buttn1 = $left->Button(-text=>'Addition', -borderwidth=>5, -width=>10, -command=>sub { syntax( ) if (($path eq "")||($acc eq "")); print "\n\nScript operation is perms addition\n\n"; my $prms = new Win32::Perms($path) || die "$^E\n"; print "\nAccount '$acc' Path: " . $prms->Path() . "\n"; if ($prms->Add("$acc", FULL|FULL, ACCESS_ALLOWED_ACE_TYPE, OBJECT_INHERIT_ACE | CONTAINER_INHERIT_ACE)) { $prms->SetRecurse($path); $prms->Set( ); $prms->Dump; print "\nSuccessfully added '$acc' FULL access permission to '$path'\n"; Win32::MsgBox("Addition operation completed successfully",32,"Perms"); } exit( ); } )->pack(@pl); my $buttn2 = $right->Button(-text=>'Remove', -borderwidth=>5, -width=>10, -command=>sub { syntax( ) if (($path eq "")||($acc eq "")); my $prms = new Win32::Perms($path) || die "$^E\n"; my $indx = $prms->Get(\ my @prms_list); print "\nPath " . $prms->Path( ) . "\n"; print "\nRemove account '$acc' ACE permissions from path '$path'\n"; print "\nNumber of indexes: '$indx'\n"; while ($indx--) { my $rec_ref = $prms_list[$indx]; foreach my $entry (keys %$rec_ref) { next unless ($entry =~ /account/i ); if ($rec_ref->{$entry} =~ /$acc/i ) { print": Distruct '$indx $rec_ref->{$entry}'\n"; $prms->Remove( $indx ); $prms->SetRecurse($path); if ($prms->Set( )) { print "Successfully removed permissions\n"; Win32::MsgBox("Remove operation completed successfully",32,"Perms"); } else { print "\nFailed to remove $indx: $acc\n"; } } else { print "\n\n"; } } } exit( ); } )->pack(@pl); MainLoop; sub syntax { my ( $script ) = $0; my ( $line ) = "-" x length ( $script ); system (CLS); Win32::MsgBox("$script\n$line\n\tSyntax\nNo command line syntax available.\n However a valid path and account name must be supplied.". "\nExample\npath\n\t\\\\remote_srv\\share_name or drive letter\nAccount\n\tdomain admins or user",32,"Perms"); print <