Your question would get more response if it was readable. (Please read Writeup Formatting Tips).

The first thing you should add to you code is some error checking. Using print $obj->someCall() isn't very useful. The Perlish idiom is

$obj->someCall() or die "Error message: $! ($^E)";

Note: The $^E. This sometimes gives you a little extra information about what went wrong. The main benefit of this idiom is that the program stops at the point that something fails (preventing loads of spurios errors that occur as a knock-on effect of the first failure--and the message will tell you which line failed and where!

Below is your code cleaned up with those additions. The error messages could be made better, but that's your job.

As for the cause of your failure. Once you know what is failing and where, and what if any error message are being produced, you may then be able to work that out for yourself.

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

Examine what is said, not who speaks.
Silence betokens consent.
Love the truth but pardon error.
Lingua non convalesco, consenesco et abolesco.

In reply to Re: Win32::TaskScheduler error by BrowserUk
in thread 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.