使用sc 命令写脚本 添加和删除服务 简单应用

添加服务

@echo.服务启动......  
@echo off  
@sc create 服务名 binPath= "%~dp0\服务路径"  
@sc config 服务名 start= AUTO 
@sc config 服务名 displayname= "服务显示的名字"
@sc config 服务名 depend= Tcpip
@sc description TruckSyncService "服务描述"
@net start 服务名 
@echo off  
@echo.服务名 启动完毕! @pause

其中 %~dp0 指当前目录,  start指启动类型  depend 指依赖于哪些服务(如果有多个以/分隔)  

删除服务

@echo.开始删除服务......  
@echo off 
@net stop 服务名
@sc delete 服务名
@echo.服务名 服务删除成功...... 

@pause  

 

posted @ 2019-05-06 15:03  望着天的蜗牛  阅读(588)  评论(0编辑  收藏  举报