windows 批处理 检查并启动 windows 服务

runliuv / 2023-08-29 / 原文

windows 批处理 检查并启动 windows 服务

 

set srvname="YSWindowsService" 
sc query|find %srvname% && echo itsok || net start %srvname%

 

这段批处理意思 ,如果服务已启动,显示 itsok。没启动,则启动服务.

srvname 是windows服务名,根据你的情况修改。