Nathaniel, Thank you very much for the quick response Will try it Erich -----Original Message----- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Sent: Monday, January 23, 2006 4:17 PM To: Erich Singer Cc: activeperl@listserv.ActiveState.com Subject: Re: Monitoring scheduled tasks on windows
I have a script that does check scheduled tasks on remote machines. I think ours have a more recent version of windows but I think 2000 should be good enough. I also installed an additional module, Win32::TaskScheduler. Here are some highlights from my script: $|++; use Win32; use Win32::GUI; use Win32::OLE; use Win32::OLE qw(in with); use Win32::TaskScheduler; use Win32::Process::Info; ... $computer = $ARGV[1]; if($computer){$use_computer++;} $class = "WinMgmts:{impersonationLevel=impersonate , authority=ntlmdomain:YOURDOMAIN}!// $computer/root/cimv2:Win32_BaseService='Schedule'"; unless($computer) { $computer = Win32::NodeName(); #print 'use node name'; $class = "WinMgmts:{impersonationLevel=impersonate}!// $computer/root/cimv2:Win32_BaseService='Schedule'"; } $scheduler=Win32::TaskScheduler->New(); $scheduler->SetTargetComputer("\\\\$computer") or no_connect(); $orig_tasks = get_task_status(); %orig_tasks = %$orig_tasks; $pc = Win32::OLE->GetObject($class); ... sub get_task_status { my %tasks; foreach my $tsk ($scheduler->Enum()) { Win32::GUI::DoEvents() >= 0 or die "Program was closed"; $scheduler->Activate($tsk); substr($tsk,-4,4) = ''; $tasks{$tsk}{'status'} = -1; $scheduler->GetStatus($tasks{$tsk}{status}); $tasks{$tsk}{'code'} = -1; $scheduler->GetExitCode($tasks{$tsk}{code}); $tasks{$tsk}{'owner'} = $scheduler->GetAccountInformation(); my ($ms, $sec, $min, $hour, $day, $dayofweek, $month, $year) = $scheduler- >GetMostRecentRunTime(); $tasks{$tsk}{'last_ran'} = sprintf "%04d%02d%02d%02d%02d%02d", $year, $month, $day, $hour, $min, $sec; } return \%tasks; } ... foreach my $object2 ( Win32::OLE::in($pc->{Properties_}) ) { if($object2->{Name} eq 'State' and $object2->{Value} ne 'Running') { if($object2->{Value} eq 'Stopped') { $tip = "$computer Scheduler Stopped"; $icon = 3; modify_icon($tip,$icon); $count++; log_it(" try to start $count"); if($count <= 10) {$result = $pc->StartService();} else { $result = 8888; unless($error_displayed) { Win32::MsgBox( "Windows Task Scheduler has been stopped and can not be started!", 0, "Error" ); $error_displayed++; } } } elsif($object2->{Value} eq 'Paused') { ... Nathaniel Bartusiak Quoting Erich Singer <[EMAIL PROTECTED]>: > > Good Afternoon > > Currently I am monitoring a few scheduled tasks on some remote Windows > Servers, mainly 2000. > I have to log into the remote server and go to > Settings/ControlPanel/ScheduledTasks and check the "last result" code > I would like to automate the above by creating a report for each > remote server to be mailed to me. > My question is if there is a WMI class or any other method that can > capture the "Last Result" > Any ideas are welcome > Thanks > Erich > > > _______________________________________________ > ActivePerl mailing list > ActivePerl@listserv.ActiveState.com > To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs > _______________________________________________ ActivePerl mailing list ActivePerl@listserv.ActiveState.com To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs