Working with sc.exe and getting a error

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
maramor
Posts: 2
Joined: 08 Jun 2012 07:14

Working with sc.exe and getting a error

#1 Post by maramor » 08 Jun 2012 07:19

When I run the following command I get a Failed message? Anyone know what this means or how I can work around it? And no I don't want to use wmic or vbs LoL. This is actualy part of a batch script but I get the error when trying command on some computer and not others manually.

sc [servername] qc MSSQLServerOLAPService

[SC] QueryServiceConfig FAILED 122:

The data area passed to a system call is too small.

[SC] GetServiceConfig needs 604 bytes

foxidrive
Expert
Posts: 6031
Joined: 10 Feb 2012 02:20

Re: Working with sc.exe and getting a error

#2 Post by foxidrive » 08 Jun 2012 08:21

There's a description of the fault and a workaround mentioned here.

http://www.windows-api.com/microsoft/Win32-WMI/29556382/win32servicestartname-is-null.aspx

Hi Jeffrey.

I think I've found the problem. Apparently the CIMV2 WMI provider is using
a fixed-size buffer when it calls QueryServiceConfig(). If the buffer isn't
big enough to hold the results, it fails silently and is unable to display
many of the properties of the Win32_Service instance.
The service in question has a very long ImagePath; 545 characters (1090
bytes).
The clue was SC.EXE, which suffers from the same problem but at least
reports the error. Here's an example:
C:\>sc \\MYSERVER qc "MyService"
[SC] QueryServiceConfig FAILED 122:
The data area passed to a system call is too small.
[SC] GetServiceConfig needs 1252 bytes

When I changed the service's "ImagePath" in the registry to something
shorter, it worked:
C:\>sc \\MYSERVER qc "MyService"
[SC] QueryServiceConfig SUCCESS
SERVICE_NAME: MyService
TYPE : 10 WIN32_OWN_PROCESS
START_TYPE : 2 AUTO_START
ERROR_CONTROL : 1 NORMAL
BINARY_PATH_NAME : This is a test.
LOAD_ORDER_GROUP :
TAG : 0
DISPLAY_NAME : MyService
DEPENDENCIES :
SERVICE_START_NAME : MYDOMAIN\MyUser


Imagepath info

http://technet.microsoft.com/en-us/libr ... 10%29.aspx

maramor
Posts: 2
Joined: 08 Jun 2012 07:14

Re: Working with sc.exe and getting a error

#3 Post by maramor » 08 Jun 2012 09:16

Thank you that got me to the answer.

sc [servername] qc MSSQLServerOLAPService <buffersize>
sc [servername] qc MSSQLServerOLAPService 5000

Note, I could have added 1024+604 since that is what the error asked for but just incase my batch asked for a service that needs more it should have plenty.

foxidrive
Expert
Posts: 6031
Joined: 10 Feb 2012 02:20

Re: Working with sc.exe and getting a error

#4 Post by foxidrive » 08 Jun 2012 09:40

That's good. Thanks for providing the followup.

Post Reply