how to start Sql Server Agent from VC++?
-
Hi, Is is it possible to check if SQL Server Agent is running and if it is not running start it to schedule tasks from MFC app in VC++.net Any help is highly apprecited! Thankx
SQL Server Agent run as Service in Window2000 and above So u have to use service api' to achieve that. here are API's 1->OpenScManager -->open Service Database of local system 2->OpenService -> Open the Particular service //now check Status of Service 3->QueryServiceStatus and to run service 4->StartService and to stop service ControlService or you can look at this article http://www.codeproject.com/useritems/AMFSServiceManager.asp[^] ----------------------------- "I Think It Will Help" ----------------------------- Alok Gupta visit me at http://www.thisisalok.tk
-
SQL Server Agent run as Service in Window2000 and above So u have to use service api' to achieve that. here are API's 1->OpenScManager -->open Service Database of local system 2->OpenService -> Open the Particular service //now check Status of Service 3->QueryServiceStatus and to run service 4->StartService and to stop service ControlService or you can look at this article http://www.codeproject.com/useritems/AMFSServiceManager.asp[^] ----------------------------- "I Think It Will Help" ----------------------------- Alok Gupta visit me at http://www.thisisalok.tk
-
I got a little proglem here though The computer which I am interested in is on LAN. that is the computer running SQL SERVER and where SQLSERVERAGENT service should be running. the problem is OpenSCManager function returns RPC server not available if I use the following call: ::OpenSCManager( "\\servername", SERVICES_ACTIVE_DATABASE, SC_MANAGER_ALL_ACCESS ); and it paase and returns a handle if I make this call hscManager = ::OpenSCManager( "servername", SERVICES_ACTIVE_DATABASE, SC_MANAGER_ALL_ACCESS ); the subsequent call to ::OpenService passes if i do this hscService = ::OpenService( hscManager, serviceName, SERVICE_ALL_ACCESS ); but then the call to QueryServiceStatus fails if i do the following ::QueryServiceStatus( hscService, lpServiceStatus ) the error code says Invalid Handle (i assume hscService ). What am i doing wrong here? If the calls to openscmanager and openservice paas the QueryServiceStatus fails. but if I append "\\" to the servername the openscmanager fails. what is going on here?? Anyone can help?