http://www.perlmonks.org?node_id=171105


in reply to Re: Win32 Task Scheduler Monitor
in thread Win32 Task Scheduler Monitor

Thank you, Courage. Attached modified code, it still got 0 task list back. And here is my configuration information for your reference:
OS:Win2000 Professional Perl:ActiveState 5.005_02 Win32::AdminMisc:NAME="Win32-AdminMisc",VERSION="0,2000,07,08"
use strict; use Win32::AdminMisc; my $server="\\\\twjimmywang"; my %JobInfo; my $Day; my @DOM; my %Jobs; my $Number; if (Win32::AdminMisc::ScheduleGet($server, 3, \%JobInfo)){ foreach $Day (1..31){ push(@DOM, $Day) if ($JobInfo{DOM} & 2**$Day); } print "This job will run on the following days of the month:\n"; print join(", ", @DOM); } print "==>".%JobInfo."\n"; Win32::AdminMisc::ScheduleList($server, \%Jobs); print "==>".%Jobs."\n"; foreach $Number (keys(%Jobs)){ print "Job $Number is $Jobs{$Number}->{Command}\n"; }

Replies are listed 'Best First'.
Re: Re: Win32 Task Scheduler Monitor
by Courage (Parson) on Jun 04, 2002 at 16:42 UTC
    well, my luck here is probably better that yours, because your latest unmodified script works with some non-zero results, after I added a task. Look:
    D:\>at 20:20 /interactive /every:5 calc Added a new job with job ID = 2 D:\Personal\perl\admin\tst>perl -w am.pl ==>0 ==>1/8 Job 2 is calc
    1/8 is hash in scalar context, you ignore "8" and see that you have one single key in that hash.

    Slightly reorganize code and see that we've got what we searched for:

    use strict; use Win32::AdminMisc; my $server="\\\\serverserversevverv"; my %JobInfo; my $Day; my @DOM; my %Jobs; my $Number; Win32::AdminMisc::ScheduleList($server, \%Jobs); print "==>".%Jobs."\n"; foreach $Number (keys(%Jobs)){ print "Job $Number is $Jobs{$Number}->{Command}\n"; if (Win32::AdminMisc::ScheduleGet($server, $Number, \%JobInfo)){ foreach $Day (1..31){ push(@DOM, $Day) if ($JobInfo{DOM} & 2**$Day); } print "This job will run on the following days of the month:\n +"; print join(", ", @DOM); } }
    the output is not that bad in my case:
    D:\Personal\perl\admin\tst>perl -w am.pl ==>2/8 Job 2 is calc This job will run on the following days of the month: 4Job 3 is calc This job will run on the following days of the month: 4, 18

    let me know if you need more details.

    Courage, the Cowardly Dog.
    PS. Something fishy is going on there, or my name is Vadim Konovalov. And it's not.

      Yes, Courage. You make it so clear. I can get the same result as yours, and I also know the difference between us. I did the schedule through Task Scheduler (Setting->Control Pannel->Scheduled Tasks, which Win2000 called Task Scheduler). Task scheduler has more control but can't be checked by AdminMisc::ScheduleGet. I have to set user account for scheduled task, but AT command doesn't support account setting. Any idea or suggestion?
        Yes, there *IS* a way! See Re: Win32 Task Scheduler Monitor. (to avoid deep re:re:re...)

        I am proud of finding such short yet capable way of doing things on Win32. :)

        Courage, the Cowardly Dog.
        PS. Something fishy is going on there, or my name is Vadim Konovalov. And it's not.