Sorry Stanley,

      I  just stumbled on the answer of SeeTargetComputer. Perl is very new
to me. I'll try my best though. Can you send me your code?  I can have a
look and let you know if I see anything. I did run the code below on 12
Win2k Servers (4 DC's and 8 file servers.) Didn't run into the problem you
are having....

Thanks,

Jason Murray
IBM Global Services, Server Platforms Team, Intel division
Why live in the Thick of Thin things.

Ph: 416.926.3000 Ext 5758  Fax: 416.926.5234
Cell:416.459.6925 Pager:416.329.1443
mailto: [EMAIL PROTECTED]


                                                                                       
                                              
                      <Stanley.G.Martin@mail.                                          
                                              
                      sprint.com>                    To:       
[EMAIL PROTECTED], [EMAIL PROTECTED]  
                                                     cc:                               
                                              
                      05/23/2002 04:34 PM            Subject:  RE: Task Scheduler      
                                              
                                                                                       
                                              
                                                                                       
                                              




I'm having a problem on SOME but NOT ALL of my Win2k boxes with the
Enum() method.  It's very consistent on these particular servers in that
it is successful on the SetTargetComputer method, but the array is empty
after execution of the Enum method.  Any thoughts on that?

Stanley G. Martin
Sprint - ISS Enterprise App/Decision Support Services
[EMAIL PROTECTED]


-----Original Message-----
From: Jason.Murray [mailto:[EMAIL PROTECTED]]
Sent: Thursday, May 23, 2002 8:24 AM
To: Perl-Win32-Users
Subject: Re: Task Scheduler


Got it.

#################################
#     Read Schedules Tasks    #
#################################


use strict;
use Win32::TaskScheduler;

####################Varibles###################

my $scheduler;
my $count;
my @jobs;
my $jobName;
my $result;
my $AccountInformation;
my $ApplicationName;
my $Parameters;
my $WorkingDirectory;
my $Priority;
my $Creator;
my $HostName; # Name of the server this will run on.

##############################################


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

$scheduler->SetTargetComputer("\\\\MachineName");

#Enumerate the jobs on the selected server.
@jobs = $scheduler->Enum();

$count=0;

      while ($count < @jobs) {

      $jobName=$jobs[$count];
      $jobName=~(s/\.job//);
      print "Job Name: $jobName\n";

      #Sets the job on which the package will operate from now on. The
name
must be without the .job extension and result will be:
      $result = $scheduler->Activate($jobName);

      #Returns the username for the currently active job or undef in
case
of error.
      if (defined $scheduler-> GetAccountInformation()) {
            $AccountInformation = $scheduler-> GetAccountInformation();
            print "Account Information: $AccountInformation\n";
      }else{ print "The Account Information is not Defined\n";
      }



      #Gets the command that will be executed at the time specified for
this scheduled task.
      if (defined $scheduler-> GetApplicationName()) {
            $ApplicationName = $scheduler-> GetApplicationName();
            print "Application Name: $ApplicationName\n";
      }else{ print "The Application Name Information is not Defined\n";
      }


      # Gets the parameters passed to the command that will be executed
at
the time specified for this scheduled task.
      if (defined $scheduler-> GetApplicationName()) {
            $Parameters = $scheduler->GetParameters();
            print "Parameters: $Parameters\n";
      }else{ print "The Parameters Information is not Defined\n";
      }

      # Gets the working directory for this scheduled task.
      if (defined $scheduler-> GetWorkingDirectory()) {
      $Parameters = $scheduler->GetParameters();
            print "Working Directory: $WorkingDirectory\n";
      }else{ print "The Working Directory Information is not Defined\n";
      }



      # Gets the priority associated with the currently selected task.
      #if (defined $scheduler-> GetPriority()) {
      #     print "The Priority Information is Defined\n";
      #     $Priority = $scheduler-> GetPriority($jobName);
      #     print "Priority: $Priority\n";
      #}else{ print "The Priority Information is Not Defined\n";
      #     }


      #Returns the creator of the currently selected task. Returns undef
on
error.
      if (defined $scheduler-> GetCreator()) {
            $Creator = $scheduler->GetCreator();
            print "Creator: $Creator\n";
      }else{ print "The Creator Information is Not Defined\n";
      }
      print "\n\n";

      $count++;
      }


Thanks,

Jason Murray
IBM Global Services, Server Platforms Team, Intel division
Why live in the Thick of Thin things.

Ph: 416.926.3000 Ext 5758  Fax: 416.926.5234
Cell:416.459.6925 Pager:416.329.1443
mailto: [EMAIL PROTECTED]
mailto: [EMAIL PROTECTED]




                      <[EMAIL PROTECTED]>

                      Sent by:                                    To:
[EMAIL PROTECTED]
                      [EMAIL PROTECTED]        cc:

                      veState.com
Subject:  Task Scheduler





                      05/22/2002 11:54 PM









Hey all,

      New to the perl idea. I put this script together to list all the
scheduled tasks on a machine. Works fine locally. I try to use the

$result SetTargetComputer($hostName)

and hit a brick wall. Can someone help me out.The goal is feed the
script a
machine name $Hostname = /\\Machinename/; and get a list of tasks.

The following runs local with no problem.
#################################
#     Read Scheduled Tasks    #
#################################


use strict;
use Win32::TaskScheduler;

####################Varibles###################

my $scheduler;
my $count;
my @jobs;
my $jobName;
my $result;
my $AccountInformation;
my $ApplicationName;
my $Parameters;
my $WorkingDirectory;
my $Priority;
my $Creator;

##############################################

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

$count=0;
while ($count < @jobs) {

$jobName=$jobs[$count];

$jobName=~(s/\.job//);

print "Job Name: $jobName\n";

#Sets the job on which the package will operate from now on. The name
must
be without the .job extension and result will be:
$result = $scheduler->Activate($jobName);

#Returns the username for the currently active job or undef in case of
error.
if (defined $scheduler-> GetAccountInformation()) {
      $AccountInformation = $scheduler-> GetAccountInformation();
      print "Account Information: $AccountInformation\n";
}else{ print "The Account Information is not Defined\n";
      }



#Gets the command that will be executed at the time specified for this
scheduled task.
if (defined $scheduler-> GetApplicationName()) {
      $ApplicationName = $scheduler-> GetApplicationName();
      print "Application Name: $ApplicationName\n";
}else{ print "The Application Name Information is not Defined\n";
      }


# Gets the parameters passed to the command that will be executed at the
time specified for this scheduled task.
if (defined $scheduler-> GetApplicationName()) {
      $Parameters = $scheduler->GetParameters();
      print "Parameters: $Parameters\n";
}else{ print "The Parameters Information is not Defined\n";
      }

# Gets the working directory for this scheduled task.
if (defined $scheduler-> GetWorkingDirectory()) {
      $Parameters = $scheduler->GetParameters();
      print "Working Directory: $WorkingDirectory\n";
}else{ print "The Working Directory Information is not Defined\n";
      }



# Gets the priority associated with the currently selected task.
#if (defined $scheduler-> GetPriority()) {
#     print "The Priority Information is Defined\n";
#     $Priority = $scheduler-> GetPriority($jobName);
#     print "Priority: $Priority\n";
#}else{ print "The Priority Information is Not Defined\n";
#     }


#Returns the creator of the currently selected task. Returns undef on
error.
if (defined $scheduler-> GetCreator()) {
      $Creator = $scheduler->GetCreator();
      print "Creator: $Creator\n";
}else{ print "The Creator Information is Not Defined\n";
      }
print "\n\n";

$count++;
}

How do I get $result SetTargetComputer($hostName)to use a UNC machine
name?

I tried
#################################
#     Read Scheduled Tasks    #
#################################


use strict;
use Win32::TaskScheduler;

####################Varibles###################

my $scheduler;
my $count;
my @jobs;
my $jobName;
my $result;
my $AccountInformation;
my $ApplicationName;
my $Parameters;
my $WorkingDirectory;
my $Priority;
my $Creator;
my $HostName; # Name of the server this will run on.

##############################################

$HostName = /\\machinename/;

#Sets the host on which the package will operate from now on. The name
must
be a valid UNC name (e.g.: \\myhost). Result will be:
$result = Win32::TaskScheduler->SetTargetComputer($HostName);

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

#Enumerate the jobs on the selected server.
@jobs = $scheduler->Enum();

$count=0;
while ($count < @jobs) {

$jobName=$jobs[$count];
$jobName=~(s/\.job//);
print "Job Name: $jobName\n";

#Sets the job on which the package will operate from now on. The name
must
be without the .job extension and result will be:
$result = $scheduler->Activate($jobName);

#Returns the username for the currently active job or undef in case of
error.
if (defined $scheduler-> GetAccountInformation()) {
      $AccountInformation = $scheduler-> GetAccountInformation();
      print "Account Information: $AccountInformation\n";
}else{ print "The Account Information is not Defined\n";
      }



#Gets the command that will be executed at the time specified for this
scheduled task.
if (defined $scheduler-> GetApplicationName()) {
      $ApplicationName = $scheduler-> GetApplicationName();
      print "Application Name: $ApplicationName\n";
}else{ print "The Application Name Information is not Defined\n";
      }


# Gets the parameters passed to the command that will be executed at the
time specified for this scheduled task.
if (defined $scheduler-> GetApplicationName()) {
      $Parameters = $scheduler->GetParameters();
      print "Parameters: $Parameters\n";
}else{ print "The Parameters Information is not Defined\n";
      }

# Gets the working directory for this scheduled task.
if (defined $scheduler-> GetWorkingDirectory()) {
      $Parameters = $scheduler->GetParameters();
      print "Working Directory: $WorkingDirectory\n";
}else{ print "The Working Directory Information is not Defined\n";
      }



# Gets the priority associated with the currently selected task.
#if (defined $scheduler-> GetPriority()) {
#     print "The Priority Information is Defined\n";
#     $Priority = $scheduler-> GetPriority($jobName);
#     print "Priority: $Priority\n";
#}else{ print "The Priority Information is Not Defined\n";
#     }


#Returns the creator of the currently selected task. Returns undef on
error.
if (defined $scheduler-> GetCreator()) {
      $Creator = $scheduler->GetCreator();
      print "Creator: $Creator\n";
}else{ print "The Creator Information is Not Defined\n";
      }
print "\n\n";

$count++;
}

I get the following  error...

C:\bin\Pl>readtasks1.pl
        MISC.H: argument is not hash.
        MISC.H: argument is not hash.
Win32::TaskScheduler: fatal error: null pointer, call NEW()
Job Name: Acrobat Reader 5
Account Information: <userid>
Application Name: C:\PROGRA~1\Adobe\ACROBA~1.0\Reader\AcroRd32.exe
Parameters:
Working Directory:
Creator: <userid>

Acrobat Reader 5 is a local schedule task ...

Sorry to bug ya.

Thanks,

Jason Murray
IBM Global Services, Server Platforms Team, Intel division
Why live in the Thick of Thin things.

Ph: 416.926.3000 Ext 5758  Fax: 416.926.5234
Cell:416.459.6925 Pager:416.329.1443
mailto: [EMAIL PROTECTED]
mailto: [EMAIL PROTECTED]

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





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






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

Reply via email to