Automatically Startup Windows Service on Bootup RRS feed

  • Question

  • Hi,

    I would like to create a windows service which automatically starts on startup and calls my function.I dont want to use .NET support for this.
    Using ATL I have taken a windows service project.I build it and registered the service using "/Service" which is then shown in Services with "Manual Startup type". I would want this to be automatic.
    How should I go about it? For this while creating the service we need to specify "SERVICE_AUTO_START" flag. But this service creation is automatically done by the base class CAtlServiceModuleT.

    SC_HANDLE hService = ::CreateService(
    hSCM, m_szServiceName, m_szServiceName,
    szFilePath, NULL, NULL, _T("RPCSS\0"), NULL, NULL);

    Now How should I go about overriding the base class functions. I think I need to make use of _tWinMain() and override but Iam not sure of the approach.

    Any suggestions or relevant links would be helpful

    Tuesday, October 7, 2008 9:03 AM


  • Use ChangeServiceConfig with SERVICE_AUTO_START after CreateService. See MSDN for details.
    Andrej Hristoliubov
    • Marked as answer by satkrish Tuesday, May 11, 2010 6:31 AM
    • Unmarked as answer by satkrish Tuesday, May 11, 2010 6:32 AM
    • Marked as answer by satkrish Tuesday, May 11, 2010 6:33 AM
    Monday, October 26, 2009 3:53 AM