Skip to content

Instantly share code, notes, and snippets.

@earnhardt3rd
Created June 19, 2023 14:04
Show Gist options
  • Save earnhardt3rd/4edc02b1c3ac667b5aee86ae520a119e to your computer and use it in GitHub Desktop.
Save earnhardt3rd/4edc02b1c3ac667b5aee86ae520a119e to your computer and use it in GitHub Desktop.
require 'getopts.pl';
Getopts('m:d:t');
my $MODE = uc($opt_m) || "";
my $DEBUG = $opt_d || 0;
if (defined $opt_t) { my %TEST = &_WIN_DRIVES();}
1;
sub _WIN_DRIVES {
my $cmd1 = "reg query hklm\\system\\mounteddevices";
my $cmdX1 = `$cmd1 2>&1`;
my @LIST = split('\n',$cmdX1);
my %DRIVES_IN_USE;
for (my $i=0;$i<=scalar(@LIST)-1 ;$i++) {
if ($LIST[$i] =~ /DosDevices/) {
my $drive = $LIST[$i];
$drive =~ s/:.*//g;
$drive =~ s/.*\\//g;
$DRIVES_IN_USE{$drive}="IN-USE";
}
}
return %DRIVES_IN_USE;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment