Submits a batch job to a batch queue. The caller must have submit access to the named queue. The job is described in the BATCH_JOB_INFO_2 structure. Default values for this structure have been defined, see Default Values for QueueBatchJob.
Syntax
DWORD QueueBatchJob(LPCTSTR queue, BATCH_JOB_INFO_2 jobinfo, LPBYTE jobid, DWORD cbsize, LPDWORD cbneeded);
Parameters
LPCTSTR queue |
Specifies the full queue name to which the job is submitted. |
BATCH_JOB_INFO_2 jobinfo |
Points to a structure identifying the attributes of the job. |
LPBYTE jobid |
Points to a buffer that will receive the job identifier. |
DWORD cbsize |
Specifies the size of the jobid buffer. This value must greater than or equal to BATCH_JOB_ID_SIZE. |
LPDWORD cbneeded |
Indicates the size of the returned information. If cbsize is too small, ERROR_INSUFFICIENT_BUFFER is returned, and cbneeded is set to the required size. |
Return Values
BATCH_ERROR_BAD_JOB_INFO |
The jobinfo structure is not complete or contains bad information. |
BATCH_ERROR_NO_SUCH_QUEUE |
The system could not find the named queue. |
BATCH_ERROR_QUEUE_NOT_ENABLED |
The specified queue was not enabled. |
BATCH_ERROR_QUEUE_ACCESS_DENIED |
The user is not allowed to submit jobs to this queue. |
BATCH_ERROR_BAD_QUEUE_NAME |
The syntax of the queue name was invalid. |
BATCH_ERROR_NO_ACCOUNT_MAPPING |
The system was unable to map the user. |
BATCH_ERROR_BAD_SCRIPTNAME |
Either the script does not exist, or the system was unable to open it for read access. |
BATCH_ERROR_BAD_JOB_PRIORITY |
The job priority was invalid. |
BATCH_ERROR_BAD_RUN_PRIORITY |
The run priority was invalid. |
BATCH_ERROR_INVALID_HOLD |
A hold other than a user hold was specified. |
BATCH_ERROR_BAD_JOB_FLAG |
An invalid job flag was specified. |
BATCH_ERROR_QUEUE_RUN_ PRIORITY_EXCEEDED |
The run priority of the job is greater than the run priority of the queue. |
Example Program
#include <iostream.h>
#include "batchapi.h"
#define MAX_LENGTH 25
void main()
{
LPBYTE JobId;
DWORD ReturnVal;
DWORD Need;
BATCH_JOB_INFO_2 NewJob;
LPCTSTR QueName;
char * pTempQue=NULL;
char * pTempScript=NULL;
cout << " STARTING THE EXECUTION OF QUEUEBATCHJOB API "<< endl;
pTempQue = new char[MAX_LENGTH];
if (pTempQue == NULL){
cout << "unable to allocate the memory.\n Exiting the program"<<endl;
exit(0);
}
pTempScript = new char[MAX_LENGTH];
if (pTempScript == NULL){
cout << "unable to allocate the memory.\n Exiting program"<<endl;
delete [] pTempQue;
exit(0);
}
cout << " Enter the name of queue to which the job should be submitted ";
cin >> pTempQue;
QueName = (const char *)pTempQue;
JobId = (LPBYTE)LocalAlloc(0,BATCH_JOB_ID_SIZE);
if (JobId == NULL ) {
cout << "unable to allocate the memory.\n Exiting"<<endl;
delete [] pTempScript;
delete [] pTempQue;
exit(0);
}
ZeroMemory(&NewJob, sizeof NewJob);
NewJob.script=(char *)pTempScript;
cout<<endl << "please enter the standard output filename " ;
cin >> strOut;
NewJob.Stdout=(LPTSTR)strOut;
cout<<endl << "please enter the standard error filename " ;
cin >> strErr;
NewJob.Stderr=(LPTSTR)strErr;
ReturnVal = QueueBatchJob(QueName,NewJob,JobId,BATCH_JOB_ID_SIZE,&Need);
switch(ReturnVal)
{
case BATCH_ERROR_BAD_JOB_INFO :
cout << " The jobinfo structure is not complete or contains bad information." << endl;
break;
case BATCH_ERROR_NO_SUCH_QUEUE :
cout << " The system could not find the named queue. " << endl;
break;
case BATCH_ERROR_QUEUE_NOT_ENABLED :
cout << " The specified queue was not enabled. " << endl;
break;
case BATCH_ERROR_QUEUE_ACCESS_DENIED :
cout << " The user is not allowed to submit jobs to this queue. " << endl;
break;
case BATCH_ERROR_BAD_QUEUE_NAME :
cout << " The syntax of the queue name was invalid." << endl;
break;
case BATCH_ERROR_NO_ACCOUNT_MAPPING :
cout << " The system was unable to map the user. " << endl;
break;
case BATCH_ERROR_BAD_SCRIPTNAME :
cout << " Either the script does not exist, or the system was unable to open it for read access. "<< endl;
break;
case BATCH_ERROR_BAD_JOB_PRIORITY :
cout << " The job priority was invalid. " << endl;
break;
case BATCH_ERROR_BAD_RUN_PRIORITY :
cout << " The run priority was invalid." << endl;
break;
case BATCH_ERROR_INVALID_HOLD :
cout << " A hold other than a user hold was specified. " << endl;
break;
case BATCH_ERROR_BAD_JOB_FLAG :
cout << " An invalid job flag was specified. " << endl;
break;
case BATCH_ERROR_QUEUE_RUN_PRIORITY_EXCEEDED :
cout << " The job run priority is greater than the queue run priority." << endl;
break;
default:
cout << "SUCCESSFUL COMPLETION OF QUEUEBATCHJOB "<< endl;
}
cout << " COMPLETED THE EXECUTION OF QUEUEBATCHJOB API "<< endl;
delete [] pTempQue;
delete [] pTempScript;
LocalFree(JobId);
}