Platform SDK: Network Management |
The NetScheduleJobAdd function submits a job to run at a specified future time and date. This function requires that the schedule service be started at the computer to which the job is submitted.
Only members of the Administrators local group can successfully execute the NetScheduleJobAdd function on a remote server.
NET_API_STATUS NetScheduleJobAdd( LPCWSTR Servername, LPBYTE Buffer, LPDWORD JobId );
If the function succeeds, the return value is NERR_Success.
If the function fails, the return value is a Win32 API error code. For a list of error codes, see Error Codes.
Following are examples of how to schedule jobs using different properties supported by the NetScheduleJobAdd function.
To schedule a job that executes once
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
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
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.
Windows NT/2000: Requires Windows NT 3.1 or later.
Windows 95/98: Unsupported.
Header: Declared in Lmat.h; include Lm.h.
Library: Use Netapi32.lib.
Network Management Overview, Network Management Functions, Schedule Functions, AT_INFO, NetScheduleJobDel, NetScheduleJobEnum