Hey guys

I hope you can help.  Trying to create scheduled tasks on remote
machines with Win32-TaskScheduler, the code appears to create the task
successfully but it creates the task locally, not the specified remote
machine.

***CODE***
        use Win32::TaskScheduler;

        $scheduler = Win32::TaskScheduler->New();

        %trig=(
                'BeginYear' => 2009,
                'BeginMonth' => 5,
                'BeginDay' => 13,
                'StartHour' => 17,
                'StartMinute' => 37,
                'TriggerType' =>
$scheduler->TASK_TIME_TRIGGER_MONTHLYDOW,
                'Type'=>{
                        'WhichWeek' => $scheduler->TASK_FIRST_WEEK |
$scheduler->TASK_LAST_WEEK,
                        'DaysOfTheWeek' => $scheduler->TASK_FRIDAY |
$scheduler->TASK_MONDAY,
                        'Months' => $scheduler->TASK_JANUARY |
$scheduler->TASK_APRIL | $scheduler->TASK_JULY |
$scheduler->TASK_OCTOBER,
                },
        );
        $tsk="wibble";

        foreach $k (keys %trig) {print "$k=" . $trig{$k} . "\n";}
          $hostName = "\\\\remsvr";
        $usr = "remuser";
          $pwd = "rempw";
        $scheduler->NewWorkItem($tsk,\%trig);
        print($scheduler->SetTargetComputer($hostName));
        print(" set $hostName\n");
        print($scheduler->SetAccountInformation($usr,$pwd));
        print(" set $usr\n");
        $scheduler->SetApplicationName("winword.exe");
        $scheduler->Save();
***END CODE***

***OUTPUT***
          C:\Scripting\File_Distro>Schedule-test.pl
          BeginYear=2009
          Type=HASH(0x22704c)
          StartHour=17
          BeginMonth=5
          StartMinute=37
          TriggerType=4
          BeginDay=13
          1 set \\remsvr
          1 set remuser
***END OUTPUT***

This is the example straight out of the docs with the
SetAccountInformation and SetTargetComputer functions added.

Windows XP SP2
Perl 5.8.8 822 [280952]
Win32-TaskScheduler 2.0.2

Any help would be greatly appreciated.

Cheers


Dave

_______________________________________________
Perl-Win32-Users mailing list
[email protected]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to