TheGenius22
MIS
Hello all,
I wrote a little script and im having some trouble. It looks for a process and executes the exe if the process is not running. I cant seem to get the execute and exit part.
#!Perl -U
use strict;
use warnings;
use Win32:erfLib;
use File::Find;
my $server;
my $proc_ref = {};
my %counter;
my @FileList;
Win32:erfLib::GetCounterNames($server, \%counter);
my %r_counter = map { $counter{$_} => $_ } keys %counter;
my $obj = $r_counter{Process};
my $id = $r_counter{'ID Process'};
my $perf = new Win32:erfLib($server);
$perf -> GetObjectList($obj, $proc_ref);
$perf -> Close();
my $inst_ref = $proc_ref -> {Objects} -> {$obj} -> {Instances};
foreach my $pr (keys %{$inst_ref}) {
my $counter_ref = $inst_ref -> {$pr} -> {Counters};
foreach my $inf (keys %{$counter_ref}) {
if ($counter_ref -> {$inf} -> {CounterNameTitleIndex} == $id) {
if ($inst_ref -> {$pr} -> {Name} =~/fsremote/i) { exit; }
else { &exec_proc; }
}
}
}
sub exec_proc {
my $drv = 'c:/program files';
find(\&do_it, $drv);
foreach (@FileList) {
if (/fsremote.exe/i) {
# part where i would like to execute the exe and exit sctipt.
}
}
}
sub do_it {
my $name = $File::Find::name;
$FileList[++$#FileList] = $name;
}
Any help is greatly appreciated
I wrote a little script and im having some trouble. It looks for a process and executes the exe if the process is not running. I cant seem to get the execute and exit part.
#!Perl -U
use strict;
use warnings;
use Win32:erfLib;
use File::Find;
my $server;
my $proc_ref = {};
my %counter;
my @FileList;
Win32:erfLib::GetCounterNames($server, \%counter);
my %r_counter = map { $counter{$_} => $_ } keys %counter;
my $obj = $r_counter{Process};
my $id = $r_counter{'ID Process'};
my $perf = new Win32:erfLib($server);
$perf -> GetObjectList($obj, $proc_ref);
$perf -> Close();
my $inst_ref = $proc_ref -> {Objects} -> {$obj} -> {Instances};
foreach my $pr (keys %{$inst_ref}) {
my $counter_ref = $inst_ref -> {$pr} -> {Counters};
foreach my $inf (keys %{$counter_ref}) {
if ($counter_ref -> {$inf} -> {CounterNameTitleIndex} == $id) {
if ($inst_ref -> {$pr} -> {Name} =~/fsremote/i) { exit; }
else { &exec_proc; }
}
}
}
sub exec_proc {
my $drv = 'c:/program files';
find(\&do_it, $drv);
foreach (@FileList) {
if (/fsremote.exe/i) {
# part where i would like to execute the exe and exit sctipt.
}
}
}
sub do_it {
my $name = $File::Find::name;
$FileList[++$#FileList] = $name;
}
Any help is greatly appreciated