开发者

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!


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
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜