Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. how to start Sql Server Agent from VC++?

how to start Sql Server Agent from VC++?

Scheduled Pinned Locked Moved C / C++ / MFC
c++csharpdatabasesql-serversysadmin
4 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • V Offline
    V Offline
    venadder
    wrote on last edited by
    #1

    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

    T 1 Reply Last reply
    0
    • V venadder

      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

      T Offline
      T Offline
      ThatsAlok
      wrote on last edited by
      #2

      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

      V 1 Reply Last reply
      0
      • T ThatsAlok

        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

        V Offline
        V Offline
        venadder
        wrote on last edited by
        #3

        Thanks a lot for pointing me in right direction. I think I can manage things from here:)

        V 1 Reply Last reply
        0
        • V venadder

          Thanks a lot for pointing me in right direction. I think I can manage things from here:)

          V Offline
          V Offline
          venadder
          wrote on last edited by
          #4

          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?

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups