Description
Shuts down the batch service on the named server. The caller must have operator privileges on the server.
Syntax
DWORD BatchServerShutdown(LPCTSTR server, DWORD graceperiod);
Parameters
LPCTSTR server |
Specifies the server to shut down. If this parameter is null or empty, the local server is shut down. |
DWORD graceperiod |
Specifies the amount of time in seconds to allow currently running jobs to complete. No new jobs will be started during this period. |
Return Values
ERROR_SUCCESS |
Request successfully submitted. The server may not shut down until after the grace period. |
BATCH_ERROR_BAD_SERVER_NAME |
The syntax of the server name was not valid. |
BATCH_ERROR_OPERATOR_ACCESS_DENIED |
The user does not have operator privileges. |
Example Program
#include <iostream.h>
#include "batchapi.h"
#define MAX_LENGTH 25
void main()
{
char * pTemp;
LPCTSTR ServName;
DWORD GracePeriod;
DWORD ReturnVal;
cout << " STARTING THE EXECUTION OF BATCHSERVERSHUTDOWN API "<< endl;
pTemp = new char[MAX_LENGTH];
if (pTemp ==NULL){
cout << "unable to allocate the memory.\n Exiting"<<endl;
exit(0);
}
cout << " Enter the Name of the server to shutdown ";
cin >> pTemp;
ServName = (const char*)pTemp;
cout << " Enter the Graceperiod in which to shutdown the Server ";
cin >> GracePeriod;
ReturnVal = BatchServerShutdown(ServName,GracePeriod);
switch ( ReturnVal)
{
case ERROR_SUCCESS :
cout << " Request successfully submitted. The server may not "
<< "shut down until after the grace period." << endl;
break;
case BATCH_ERROR_BAD_SERVER_NAME :
cout << " The syntax of the server name was not valid." << endl;
break;
case BATCH_ERROR_OPERATOR_ACCESS_DENIED :
cout << " The user does not have operator privileges." << endl;
break;
default:
cout << "SUCCESSFUL COMPLETION OF SERVER SHUTDOWN"<< endl;
}
cout << " COMPLETED THE EXECUTION OF BATCHSERVERSHUTDOWN API "<< endl;
delete [] pTemp;
}