Hello monks,

First of all, I must say that I am new to the idea of programming in Perl.
I have written the program shown below which tries to call Win32::TaskScheduler in order to schedule a specific task:

use Win32::TaskScheduler;<br> sub create_schedule($$$$$$$$$$$)<br> <br> { <br> my ($mins, $hrs, $mon,$tue,$wed,$thu,$fri, <br> $sat,$sun,$target_machine,$task_name) = @_; <br> my $days;<br> print my $scheduler = Win32::TaskScheduler->New();<br> my %trig=(<br> 'BeginYear' => 2005,<br> 'BeginMonth' => 03,<br> 'BeginDay' => 20,<br> 'StartHour' => $hrs,<br> 'StartMinute' => $mins,<br> 'TriggerType' => $scheduler -> <br> TASK_TIME_TRIGGER_MONTHLYDOW,<br> 'Type'=>{<br> 'WhichWeek' => <br> $scheduler->TASK_FIRST_WEEK | $scheduler->TASK_SECOND_WEEK <br> | $scheduler->TASK_THIRD_WEEK | $scheduler->T +ASK_LAST_WEEK, 'DaysOfTheWeek' => <br> $scheduler->TASK_TUESDAY,<br> 'Months' => $scheduler->TASK_JANUARY | $scheduler->TASK_FEBRUARY <br> |$scheduler->TASK_MARCH |<br> $scheduler->TASK_APRIL | $scheduler->TASK_MAY | <br> $scheduler->TASK_JUNE | $scheduler->TASK_JULY |$scheduler->TASK_AUGUST | <br> $scheduler->TASK_SEPTEMBER | <br> $scheduler->TASK_OCTOBER | $scheduler->TASK_NOVEMBER | <br> $scheduler->TASK_DECEMBER<br> },<br> );<br> print $scheduler->SetTargetComputer("\\\\MYHOST");<br> my $tsk = $task_name;<br> my $k;<br> foreach $k (keys %trig)<br> { <br> print "$k=" . $trig{$k} . "\n";<br> } print $scheduler->NewWorkItem($tsk,\%trig); <br> print $scheduler->SetApplicationName <br> ("timezone.pm");<br> print $scheduler->Save(); <br> $scheduler = Win32::TaskScheduler->New();<br> $scheduler->Activate($task_name); <br> }

When i execute it i get the following output:

Win32 : : TaskScheduler : fatal error : null pointer, call NEW()
Win32 : : TaskScheduler : fatal error : null pointer, call NEW()

I suspect that this has to do something with the NewWorkItem function of Win32:: TaskScheduler; however the 'trig' array does not seem to have any null pointers. Also the 'timezone.pm' file is in the same folder with the code shown above.I have searched for extra documentation on CPAN and google concerning this function, but it did not help. I would be very grateful to anyone who could tell what the reason of this problem could be.

Thank you in advance,

Harry


In reply to Win32::TaskScheduler error by survivor83

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.