Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 374
  • Last Modified:

Need help deciphering the parameters for the function 'NetScheduleJobAdd()'

Greetings:

The second parameter for NetScheduleJobAdd() is a structure of type 'AT_INFO' which is defined as:

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

My question is, what is necessary to initialize this structure before it is used in the NetScheduleJobAdd function?  This structure is contained in the second parameter below:

NetScheduleJobAdd( LPWSTR Servername,  LPBYTE Buffer,   LPDWORD JobId);
 
 
0
John500
Asked:
John500
1 Solution
 
proskigCommented:
Remarks
Following are examples of how to schedule jobs using different properties supported by the NetScheduleJobAdd function.

To schedule a job that executes once

Set the DaysOfMonth member of the AT_INFO structure to zero.
Set the DaysOfWeek member to zero.
Set the JobTime member to the time the job should execute.
The job executes at the time specified by the JobTime member. After the job executes, it is deleted.

To schedule and delete a job that executes multiple times

Set the appropriate bits in the DaysOfMonth member of the AT_INFO structure.
Set the appropriate bits in the DaysOfWeek member. (You do not need to set both the DaysOfMonth and the DaysOfWeek members.)
Set the JobTime member to the time the job should execute.
The job executes at the time specified by the JobTime member, once for each day set in DaysOfMonth and DaysOfWeek. After each execution, the corresponding bit is cleared. When the last bit is cleared, the job is deleted.

To schedule a job that executes periodically

Set the appropriate bits in the DaysOfMonth member of the AT_INFO structure.
Set the appropriate bits in the DaysOfWeek member. (You do not need to set both the DaysOfMonth and the DaysOfWeek members.)
Set the JobTime member to the time the job should execute.
Set the job submission flag JOB_RUN_PERIODICALLY in the Flags member.
The job will execute periodically, at the time specified by the JobTime member, on each day set in DaysOfMonth and DaysOfWeek. The job will not be deleted as a result of the repeated executions. The only way to delete the job is by an explicit call to the NetScheduleJobDel function.

See AT_INFO for a description of the DaysOfWeek, DaysOfMonth, and job property bitmasks.

0
 
John500Author Commented:
proskig,

Thanks for the response.  I have MSDN and have read it a number of times regarding this function.  However, I still don't understand how to 'set' all of the things you mention.

In other words, it would be helpful to see code which shows the 'AT_INFO' structure actually being set.  Do you get my point?
0
 
gmleemanCommented:
Hi There

Use your code as is:

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


Then in your code:

int main(void)
{
   char ascOther[80];
   AT_INFO myATINFO;

   myATINFO.DaysOfMonth = 0;
   myATINFO.DayOfWeek = 0;

   function(&myATINFO);

}

The above shows how to initialise two elements of the stucture, and to pass the variable as a pointer to a function.

The type AT_INFO can be treated now as "int" or "char".
(The *PAT_INFO, *LPAT_INFO could be a bit confusing...)



Hope this helps
0
 
AxterCommented:
Hi gmleeman,
All of the experts here, for the most part have learn from other experts as to the proper etiquette
for posting answer.
 An answer should not be posted as an answer, if other experts have previously posted possible answers
as comments, and/or have already made contributions to the question.

There are many experts who never post answers as answer.  Instead, they post their answers as comments.
If you read the following link, you?ll see why this is the preferred method for many of our valued experts,
including myself.

http://www.experts-exchange.com/jsp/cmtyQuestAnswer.jsp


Hi John500,
Feel free to click the [Reject Answer] button near (Answer-poster's) response, even if it seems like
a good answer.
Doing so will increase your chance of obtaining additional input from other experts.  Later, you can
click the [Select Comment as Answer] button on any response.
0
 
John500Author Commented:
gmleeman,

Thanks, that's definately the answer.  I should have thought of that!!

I can post another question if you like, otherwise, do you happen to know whether this function would run for, say, 2 days by vurtue of how the 'members' are set.

In other words if the main() looks like this:

main()
{

{
  char ascOther[80];
  AT_INFO myATINFO;

  myATINFO.DaysOfMonth = 2;
  myATINFO.DayOfWeek = 1;
  myATINFO.Flag = JOB_RUN_PERIODICALLY;

  NetScheduleJobAdd(server, buffer, JobId)


 return;
}

 ... regardless of whether the members are set correctly, I just want to know whether this program is capable of running for 2 days before quitting?

Thanks
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now