David Evans <> wrote: > 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.
This is just a guess, but the example script (http://cpansearch.perl.org/src/UNICOLET/Win32-TaskScheduler2.0.3/Exampl e.pl) calls SetTargetComputer before calling Activate, so perhaps you should try moving the call to before NewWorkItem, which creates a new active task, in your script. As I said, just a guess. HTH -- Brian Raven This e-mail may contain confidential and/or privileged information. If you are not the intended recipient or have received this e-mail in error, please advise the sender immediately by reply e-mail and delete this message and any attachments without retaining a copy. Any unauthorised copying, disclosure or distribution of the material in this e-mail is strictly forbidden. _______________________________________________ Perl-Win32-Users mailing list Perl-Win32-Users@listserv.ActiveState.com To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs