[ Index ]

PHP Cross Reference of Unnamed Project

title

Body

[close]

/se3-unattended/var/se3/unattended/install/bin/ -> unlink.pl (source)

   1  # Script to delete links within special folders 
   2  # (like AllUsersDesktop).
   3  
   4  use warnings;
   5  use strict;
   6  use Getopt::Long;
   7  use Pod::Usage;
   8  use Win32::OLE;
   9  
  10  use File::Basename;
  11  use File::Spec;
  12  use File::Path;
  13  
  14  # Your usual option-processing sludge.
  15  my %opts;
  16  GetOptions (\%opts, 'help|h|?' )
  17      or pod2usage (1);
  18  
  19  (exists $opts{'help'})
  20      and pod2usage ('-exitstatus' => 0, '-verbose' => 2);
  21  
  22  # Ensure one argument after options.
  23  scalar @ARGV == 1
  24      or pod2usage (1);
  25  
  26  my ($target) = @ARGV;
  27  
  28  # Bomb out completely if COM engine encounters any trouble.
  29  Win32::OLE->Option ('Warn' => 3);
  30  
  31  # Get WshShell object.  See
  32  # <http://msdn.microsoft.com/library/en-us/script56/html/wsobjwshshell.asp>
  33  my $wsh_shell = Win32::OLE->CreateObject ('WScript.Shell');
  34  
  35  sub canonicalize_filename ($) {
  36      my ($filename) = @_;
  37  
  38      # FIXME: Add support for "ProgramFiles".  And for "QuickLaunch";
  39      # see <http://www.winnetmag.com/Files/07/9176/Listing_03.txt>.
  40      if ($filename =~ /^special:([a-z]+)(.*)/i) {
  41          my ($special, $rest) = ($1, $2);
  42          # Get special folder.  See
  43          # <http://msdn.microsoft.com/library/en-us/script56/html/wsprospecialfolders.asp>
  44  
  45          my $folder = $wsh_shell->SpecialFolders ($special);
  46          $filename = "$folder$rest";
  47      }
  48  
  49      return $filename;
  50  }
  51  
  52  $target = canonicalize_filename ($target);
  53  
  54  unlink $target;
  55  exit 0;
  56  
  57  __END__
  58  
  59  =head1 NAME
  60  
  61  unlink.pl - Remove links  on special Folders   
  62  
  63  =head1 SYNOPSIS
  64  
  65  unlink.pl <target> 
  66  
  67  Options (may be abbreviated):
  68  
  69   --help                   Display help and exit
  70  
  71  =head1 DESCRIPTION
  72  
  73  This script remove a link within special folders (special:AllUsersDesktop)
  74  
  75  =head1 EXAMPLES
  76  
  77   unlink.pl special:AllUsersDesktop\"\Adobe Reader 7.0.lnk\"
  78  
  79  =head1 SEE ALSO
  80  C<http://msdn.microsoft.com/library/en-us/script56/html/wsprospecialfolders.asp>


Generated: Tue Mar 17 22:47:18 2015 Cross-referenced by PHPXref 0.7.1