change

  $hostname = /\\machinename/;

to

  $hostname = "\\\\machinename";

Otherwise what you are saying is something more like "$hostname equals the
result of matching $_ to /\\machinename/", or something like that.

-----Original Message-----
From: [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: 5/23/02 4:29 AM
Subject: Task Scheduler

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-Admin mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
_______________________________________________
Perl-Win32-Admin mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to