#!C:\Perl\bin\perl

use warnings;
use strict;
use Win32::OLE qw(in);

$Win32::OLE::Warn = 3;

my $Pause_Drive_Command = 'bemcmd -o60';
my $UnPause_Drive_Command = 'bemcmd -o61';
my $BackupExecBins = 'C:\Program Files\Symantec\Backup Exec';

chdir($BackupExecBins);
my %Mounted_Drives;

my %Possible_Drives = (
  'G:' => 'G: Gary',
  'H:' => 'H: Henry',
  'I:' => 'I: Ian',
  'J:' => 'J: Jake',
  'K:' => 'K: Kevin',
  'L:' => 'L: Leon',
  'O:' => 'O: Olivia',
  'P:' => 'P: Patti',
  'Q:' => 'Q: Queenie',
  'R:' => 'R: Rose',
  'S:' => 'S: Sandra',
  'T:' => 'T: Tasha',
  );


my $strComputer = '.';
my $objWMI = Win32::OLE->GetObject('winmgmts:\\\\' . $strComputer . '\\root\\cimv2');
my $col_vol = $objWMI->ExecQuery('select * from Win32_Volume');

foreach my $obj_vol (in $col_vol)  {
  $Mounted_Drives{ $obj_vol->{DriveLetter} }++;
  }

foreach my $drive ( sort keys %Possible_Drives ) {
  if ( $Mounted_Drives{ $drive } ) {
    #print "This drive is mounted: " . $Possible_Drives{ $drive } . "\n";
    my $cmd = $UnPause_Drive_Command . ' -d"' . $Possible_Drives{ $drive } . '"';
    #print "$cmd\n";
    system($cmd);
    }
  else {
    #print "This drive is not mounted: " . $Possible_Drives{ $drive } . "\n";
    my $cmd = $Pause_Drive_Command . ' -d"' . $Possible_Drives{ $drive } . '"';
    #print "$cmd\n";
    system($cmd);
    }
  sleep(2);
  }

exit;