如何确定是否仅使用(最好)批处理安装了 Windows 服务? [英] How does one find out if a Windows service is installed using (preferably) only batch?

查看:26
本文介绍了如何确定是否仅使用(最好)批处理安装了 Windows 服务?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要检查是否从批处理文件安装了 Windows 服务.如果需要,我可以深入研究批处理以外的其他内容,但我不想这样做.有没有办法做到这一点?

I need to check if a Windows service is installed from a batch file. I can dip into something other than batch if I need to, but I would prefer not to. Is there any way to do this?

推荐答案

试试这个:

@echo off
SC QUERY ftpsvc > NUL
IF ERRORLEVEL 1060 GOTO MISSING
ECHO EXISTS
GOTO END

:MISSING
ECHO SERVICE MISSING

:END

请注意,SC QUERY 命令通过短服务名称而不是显示名称进行查询.您可以通过查看服务管理器中服务属性的常规"选项卡来找到此名称.

Note that the SC QUERY command queries by the short service name not the display name. You can find this name by looking at the General tab of a service's properties in Service Manager.

这篇关于如何确定是否仅使用(最好)批处理安装了 Windows 服务?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆