CJS
CJS

Reputation: 1545

Possible to detect disabled windows services with "SC query"?

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!

Upvotes: 1

Views: 5848

Answers (1)

snoone
snoone

Reputation: 5489

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

Upvotes: 5

Related Questions