def set_startup_mode(service_name, startup_type)
      startup_code = SERVICE_START_TYPES.key(startup_type)
      if startup_code.nil?
        raise Puppet::Error.new(_("Unknown start type %{start_type}") % {startup_type: startup_type.to_s})
      end
      open_service(service_name, SC_MANAGER_CONNECT, SERVICE_CHANGE_CONFIG) do |service|
        # Currently the only thing puppet's API can really manage
        # in this list is dwStartType (the third param). Thus no
        # generic function was written to make use of all the params
        # since the API as-is couldn't use them anyway
        success = ChangeServiceConfigW(
          service,
          SERVICE_NO_CHANGE,  # dwServiceType
          startup_code,       # dwStartType
          SERVICE_NO_CHANGE,  # dwErrorControl
          FFI::Pointer::NULL, # lpBinaryPathName
          FFI::Pointer::NULL, # lpLoadOrderGroup
          FFI::Pointer::NULL, # lpdwTagId
          FFI::Pointer::NULL, # lpDependencies
          FFI::Pointer::NULL, # lpServiceStartName
          FFI::Pointer::NULL, # lpPassword
          FFI::Pointer::NULL  # lpDisplayName
        )
        if success == FFI::WIN32_FALSE
          raise Puppet::Util::Windows::Error.new(_("Failed to update service configuration"))
        end
      end
    end
def set_startup_mode(service_name, startup_type)
      startup_code = SERVICE_START_TYPES.key(startup_type)
      if startup_code.nil?
        raise Puppet::Error.new(_("Unknown start type %{start_type}") % {startup_type: startup_type.to_s})
      end
      open_service(service_name, SC_MANAGER_CONNECT, SERVICE_CHANGE_CONFIG) do |service|
        # Currently the only thing puppet's API can really manage
        # in this list is dwStartType (the third param). Thus no
        # generic function was written to make use of all the params
        # since the API as-is couldn't use them anyway
        success = ChangeServiceConfigW(
          service,
          SERVICE_NO_CHANGE,  # dwServiceType
          startup_code,       # dwStartType
          SERVICE_NO_CHANGE,  # dwErrorControl
          FFI::Pointer::NULL, # lpBinaryPathName
          FFI::Pointer::NULL, # lpLoadOrderGroup
          FFI::Pointer::NULL, # lpdwTagId
          FFI::Pointer::NULL, # lpDependencies
          FFI::Pointer::NULL, # lpServiceStartName
          FFI::Pointer::NULL, # lpPassword
          FFI::Pointer::NULL  # lpDisplayName
        )
        if success == FFI::WIN32_FALSE
          raise Puppet::Util::Windows::Error.new(_("Failed to update service configuration"))
        end
      end
    end
Change the startup mode of a windows service

 @param [string] service_name the name of the service to modify
 @param [Int] startup_type a code corresponding to a start type for
  windows service, see the "Service start type codes" section in the
  Puppet::Util::Windows::Service file for the list of available codes