Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

WMI StopService

78 views
Skip to first unread message

mayayana

unread,
Dec 4, 2007, 5:09:38 PM12/4/07
to
Anyone know about the error codes for
Win32_Service StopService? I'm getting error 4
when trying to stop some services. The description
of that error is "Invalid Service Control", which tells
me nothing. I'm trying to figure out what actually
causes error 4. (I asked in the WMI group but
it seems to be rather sleepy over there, with
little activity.)

Running as only user, with full control, on XP.
I think, if I remember correctly, it was trying to
stop WebClient that raised the error.


Jeffery Hicks [MVP]

unread,
Dec 5, 2007, 8:09:51 AM12/5/07
to
You may be trying to stop a service that can't be stopped or is hung. What
happens if you use SC.EXE from the command line to stop the service?

--
Jeffery Hicks
Microsoft PowerShell MVP
http://www.scriptinganswers.com
http://www.powershellcommunity.org

Now Available: WSH and VBScript Core: TFM
Coming Soon: Windows PowerShell: TFM 2nd Ed.

"mayayana" <mayaXX...@mindXXspring.com> wrote in message
news:uTEJKKsN...@TK2MSFTNGP02.phx.gbl...

mayayana

unread,
Dec 5, 2007, 9:20:12 AM12/5/07
to

> You may be trying to stop a service that can't be stopped or is hung.
What
> happens if you use SC.EXE from the command line to stop the service?
>

Thanks. That at least narrows it down a bit. I don't
know what sc.exe is. I'll figure it out and give that a
try, though I want to do it all from within script
eventually - to the extent possible.


Jeffery Hicks [MVP]

unread,
Dec 5, 2007, 10:22:39 AM12/5/07
to
SC is a command line tool for managing services. I'm only suggesting it as a
means to troubleshoot your issue.

Now Available: WSH and VBScript Core: TFM
Coming Soon: Windows PowerShell: TFM 2nd Ed.

"mayayana" <mayaXX...@mindXXspring.com> wrote in message

news:Ovgrmo0N...@TK2MSFTNGP04.phx.gbl...

Waydaws

unread,
Dec 5, 2007, 11:21:05 PM12/5/07
to

Hi I think that error 4 would be a standard win32 error. NET HELPMSG
4 will give you what the error means, in that case.
It would mean "The system cannot open the file." I bet that still
doesn't help you ;-)

mayayana

unread,
Dec 6, 2007, 8:56:29 AM12/6/07
to

> Hi I think that error 4 would be a standard win32 error. NET HELPMSG
> 4 will give you what the error means, in that case.
> It would mean "The system cannot open the file." I bet that still
> doesn't help you ;-)

No, but you get an "A" for sense of humor. :)
I'm curious, though, what "NET HELPMSG" means.
Is that some sort of command line applet?

I explored this more last night and I think I
may have figured it out. According to the docs,
any error up to 24 is coming from WMI. I also
found a list of slightly better error descriptions.

(It's strange how MS has such a great system
of error returns for functions, but they barely
make the error names available, much less the
real meaning.)

I found this for error 4:
"The requested control code is not valid, or it is unacceptable to the
service."

I had got error 4 trying to disable WebClient.
When I looked in the services window last night,
WebClient was disabled. So I set it to manual and
re-ran my script, disabling WebClient and 20-odd
other services. This time the script checked the current
status first and then proceeded with the disable call
only if the service was not already disabled. It worked
without error. So, I'm not certain yet, but it appears
that error 4 can happen when one tries to set a service
(ChangeStartMode) to the same mode it's currently in.

I don't know whether there are many people who
care about all of this, but just in case, I'm pasting
in the better list of error descriptions I found for
ChangeStartMode, StopService, StartService.

1 - The request is not supported. 2 - The user did not have the necessary
access. 3 - The service cannot be stopped because other services that are
running are dependent on it. 4 - The requested control code is not valid, or
it is unacceptable to the service. 5 - The requested control code cannot be
sent to the service because the state of the service
(Win32_BaseService:State) is equal to 0, 1, or 2. 6 - The service has not
been started. 7 - The service did not respond to the start request in a
timely fashion. 8 - Unknown failure when starting the service. 9 - The
directory path to the service executable was not found. 10 - The service is
already running. 11 - The database to add a new service is locked. 12 - A
dependency for which this service relies on has been removed from the
system. 13 - The service failed to find the service needed from a dependent
service. 14 - The service has been disabled from the system. 15 - The
service does not have the correct authentication to run on the system. 16 -
This service is being removed from the system. 17 - There is no execution
thread for the service. 18 - There are circular dependencies when starting
the service. 19 - There is a service running under the same name. 20 - There
are invalid characters in the name of the service. 21 - Invalid parameters
have been passed to the service. 22 - The account, which this service is to
run under is either invalid or lacks the permissions to run the service.
23 - The service exists in the database of services available from the
system. 24 - The service is currently paused in the system. Other - For
integer values other than those listed above, refer to Win32 error code
documentation. defined in Win32_Service.


Waydaws

unread,
Dec 7, 2007, 1:02:12 AM12/7/07
to

Well that makes sense! Can't stop a service that is stopped so you get
the invalid service control is not valid. Yeah, guess we should have
checked msdn for the service specific codes in the first place:

http://msdn2.microsoft.com/en-us/library/aa393673.aspx

Well, at least it's a lesson learned, and I'll take it into account
when I end up doing that. Check status first before controlling.

Anyway, net helpmsg error-code is just one of the options to the NET
command (as in NET use, or NET session, NET print...). As you
mentioned, that wasn't for win32service. I find it helpful if you
look at an iis log, it's reports a Win32_status field, usually it just
verifies what the protocol (http, ftp..) error would be.

mayayana

unread,
Dec 7, 2007, 8:55:56 AM12/7/07
to
> Anyway, net helpmsg error-code is just one of the options to the NET
> command (as in NET use, or NET session, NET print...). As you
> mentioned, that wasn't for win32service. I find it helpful if you
> look at an iis log, it's reports a Win32_status field, usually it just
> verifies what the protocol (http, ftp..) error would be.
>

Thanks. Could you point me to info. about that?
I don't know what you're talking about. I've no
experience with Windows servers and am only just
getting around to delving into the details of XP.
There seem to be a lot of network admins who hang
around here and who like to use various command line
utilities, but most of that sort of thing is new to me.


Paul Randall

unread,
Dec 7, 2007, 8:09:14 PM12/7/07
to

"mayayana" <mayaXX...@mindXXspring.com> wrote in message
news:uBKGQkNO...@TK2MSFTNGP02.phx.gbl...

On XP, in help & support, search for command line reference a-z. You
should find a very close match. When you click that link, it opens
C:\WINDOWS\Help\ntcmds.chm in a sub window of Help & Support, but you
can open that file in its own window so less of your screen is wasted.
You will find info on a wide variety of handy tools that comes with
Windows.

-Paul Randall


mayayana

unread,
Dec 8, 2007, 6:09:36 PM12/8/07
to
> On XP, in help & support, search for command line reference a-z. You
> should find a very close match. When you click that link, it opens
> C:\WINDOWS\Help\ntcmds.chm in a sub window of Help & Support, but you
> can open that file in its own window so less of your screen is wasted.
> You will find info on a wide variety of handy tools that comes with
> Windows.
>
Thanks. I removed PCHealth, which seems
to demolish Help and Support, but maybe I
can track down that file. (I never guessed
that I might actually want Windows help for
something. :)


0 new messages