tags:

views:

17

answers:

1

I have a Windows Service (written in Java) that needs to start other Windows Services under certain circumstances. I do this by simply pumping out "sc" commands to the command line.

If the windows service I'm trying to start is disabled, the startup will obviously fail. I'd like to determine this beforehand and not bother to trying to start it up.

However, if the "disabled" state is somewhere in the "sc query" command, I have yet to find it. Is there any way I can detect if a windows service is disabled in Java, preferably though the command line?

Thanks!

+1  A: 

The query config option tells you the Start type of the service:

C:\Users\snoone>sc qc vmtools
[SC] QueryServiceConfig SUCCESS

SERVICE_NAME: vmtools
        TYPE               : 110  WIN32_OWN_PROCESS (interactive)
        START_TYPE         : 2   AUTO_START
        ERROR_CONTROL      : 1   NORMAL

Does that help?

-scott

snoone
Perfect - thanks! Totally obvious in retrospect :)
CJS
Obvious once you know it :)
snoone