@echo off REM 定义服务名称变量 set SERVICE_NAME=RemoteClient REM 检查服务状态 sc query %SERVICE_NAME% | findstr RUNNING > nul if %errorlevel% equ 0 ( echo %SERVICE_NAME% is already running. ) else ( REM 启动服务 net start %SERVICE_NAME% if %errorlevel% equ 0 ( echo %SERVICE_NAME% has been started successfully. ) else ( echo %SERVICE_NAME% failed to start. ) )
标签:bat,判断,服务,SERVICE,启动,errorlevel%,echo,NAME%,REM From: https://www.cnblogs.com/nanfei/p/17388319.html