[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Interacting with NT Schedule Service

Posted on 1997-08-18
1
Medium Priority
?
291 Views
Last Modified: 2010-04-06
I am writing an application to interact with the NT Schedule service but I have not been able to find any documentation or references to this. Specifically I want to know how to get a list of currently scheduled jobs, how to add a job and how to delete a job. These functions are available at command line but I need to have my application talk directly to the service. Presumeably there are API calls to handle this. Any assistance or guidance would be appreciated. Also please use "newbiespeak" in any response. :-)

Kurt
0
Comment
Question by:kurt11
1 Comment
 
LVL 3

Accepted Solution

by:
mirek071497 earned 300 total points
ID: 1341797
Schedule service functions are :
  - job submittal (NetScheduleJobAdd),
  - job cancellation (NetScheduleJobDel),
  - job enumeration (NetScheduleJobEnum),
  - retrieving information about a particular job (NetScheduleJobGetInfo).
In order for these functions to succeed, a caller must have administrator's
privilege at a computer where Schedule service is running.

This functions is in Win32.hlp but without structures.


Data Structures

AT_INFO data structure is used by NetScheduleJobAdd( ) to specify
a job to be added, and by NetScheduleJobGetInfo( ) to return
information about an already submitted job.

AT_ENUM data structure is used by NetScheduleJobEnum( ) to enumerate
and return information about an entire queue of already submitted jobs.


typedef struct _AT_INFO {
      DWORD      JobTime;
      DWORD      DaysOfMonth;
      UCHAR      DaysOfWeek;
      UCHAR      Flags;
      LPWSTR      Command;
} AT_INFO, *PAT_INFO, *LPAT_INFO;

typedef struct _AT_ENUM {
      DWORD      JobId;
      DWORD      JobTime;
      DWORD      DaysOfMonth;
      UCHAR      DaysOfWeek;
      UCHAR      Flags;
      LPWSTR      Command;
} AT_ENUM, *PAT_ENUM, *LPAT_ENUM;

JobId      -Job identifier of an already submitted job.
JobTime    -Time of day when a job is scheduled to run.
            Time is a local time at a computer where Schedule service
            is running. Time is measured from midnight
            and is expressed in milliseconds.
DaysOfMonth-Bitmask for days of month when a job is scheduled
            to run. The bitmask is NULL if a job was scheduled
            to run only once at the first occurrence of JobTime.
            For each bit that is set in the bitmask a job
            will run at JobTime on a corresponding day of the month.
            Bit 0 corresponds to first day of the month, etc.
DaysOfWeek -Bitmask for days of week when this job is scheduled to run.
            The bitmask is NULL if a job was scheduled to run only once
            at the first occurrence of JobTime.
            For each bit that is set in the bitmask a job will run
            at JobTime on a corresponding day of the week.
            Bit 0 corresponds to Monday (first day of the week), etc.
Flags      -Bitmask describing job properties.
            For job submission (NetScheduleJobAdd) possible values are:
            JOB_RUN_PERIODICALLY
              If this flag bit is set then job runs on every day
              where corresponding bits in DaysOfMonth or DaysOfWeek
              are set. If this flag bit is clear then job runs
              only once for each bit that was set in DaysOfMonth
              and/or DaysOfWeek at the time of job submission.
            JOB_ADD_CURRENT_DATE
              When this flag bit is set then job will also execute
              at the first occurrence of JobTime at the computer
              where job is submitted to. In other words,
              setting this flag bit is equivalent to setting
              the corresponding day bit in DaysOfMonth bitmask.

            For job information retrieval
              (NetScheduleJobEnum and NetScheduleJobGetInfo) possible
              values are:
              JOB_RUN_PERIODICALLY
                This flag bit is equal to the original value
                of this flag bit when a job was submitted.
              JOB_EXEC_ERROR
                This flag bit is set whenever Schedule service
                failed to execute successfully this job
                the last time this job was supposed to run.
              JOB_RUNS_TODAY
                This flag bit is set if JobId is larger
                than the current time of day at the computer
                where this job is queued at.
Command     -Points to a Unicode string that contains the name
             of command, batch program or binary file to execute.


0

Featured Post

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
Loops Section Overview
As many of you are aware about Scanpst.exe utility which is owned by Microsoft itself to repair inaccessible or damaged PST files, but the question is do you really think Scanpst.exe is capable to repair all sorts of PST related corruption issues?
Suggested Courses

872 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question