PRB: CreateService or ChangeServiceConfig Fails with Error 31

ID: Q154667

3.51 WINDOWS NT kbprg kbprb

The information in this article applies to:

SYMPTOMS

The CreateService or ChangeServiceConfig API fails with the error code 31, ERROR_GEN_FAILURE, on Windows NT 3.51.

CAUSE

When obtaining a handle to the Service Control Manager via the OpenScManager API, a machine name is specified in the first parameter. If the machine name specified refers to the local machine, the ChangeServiceConfig and CreateService APIs will fail with an error code of 31, ERROR_GEN_FAILURE, if the name was specified without appending two backslashes (\) in front of the machine name. For example:

   franki

RESOLUTION

Append two backslashes in front of the computer name for the first parameter to OpenScManager(). For example:

   \\franki

The CreateService and ChangeServiceConfig API will now successfully execute.

STATUS

This behavior is by design.

MORE INFORMATION

The error code 31, ERROR_GEN_FAILURE, will only occur with the CreateService and ChangeServiceConfig API when the following conditions are met:

KBCategory: kbprg kbprb KBSubcategory: BseService Additional reference words: 3.51 kbdss
Keywords          : kbKernBase kbService kbGrpKernBase 
Version           : 3.51
Platform          : NT WINDOWS

Last Reviewed: January 13, 1997