Solved

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

Posted on 2001-06-14
5
312 Views
Last Modified: 2008-01-16
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
Comment
Question by:John500
5 Comments
 
LVL 5

Expert Comment

by:proskig
ID: 6190825
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
 

Author Comment

by:John500
ID: 6190991
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
 
LVL 3

Accepted Solution

by:
gmleeman earned 50 total points
ID: 6191394
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
 
LVL 30

Expert Comment

by:Axter
ID: 6191420
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
 

Author Comment

by:John500
ID: 6191472
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

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

When writing generic code, using template meta-programming techniques, it is sometimes useful to know if a type is convertible to another type. A good example of when this might be is if you are writing diagnostic instrumentation for code to generat…
What is C++ STL?: STL stands for Standard Template Library and is a part of standard C++ libraries. It contains many useful data structures (containers) and algorithms, which can spare you a lot of the time. Today we will look at the STL Vector. …
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

762 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now