SC命令:安装、开启、配置、关闭windows服务 bat批处理

一、直接使用cmd来进行服务的一些操作
1、安装服务
sc create chengxu binPath= “C:\test.exe”
其中:chengxu为创建的服务名,binPath后面是运行exe文件的所在路径
2、配置服务
有以下集中方式:
sc config 服务名 start=AUTO (自动)
sc config 服务名 start= DEMAND (手动)
sc config 服务名 start= DISABLED(禁用)
例如下面的命令,在XP系统中开机便会自动启动:
sc config chengxu start= AUTO
3、开启服务
net start chengxu
4、关闭服务
net stop chengxu
5、删除服务
sc delete chengxu
二、为方便使用,可编辑为bat批处理文件
(新建一个txt文件,自己命名,把后缀改为.bat文件)
1、创建、配置、开启服务
@echo.服务启动……
@echo off
@sc create chengxu binPath= “C:\test.exe”
@net start chengxu
@sc config chengxu start= AUTO
@echo off
@echo.启动完毕!
@pause
2、关闭服务
@echo.服务关闭
@echo off
@net stop chengxu
@echo off
@echo.关闭结束!
@pause
3、删除服务
@echo.服务删除
@echo off
@sc delete chengxu
@echo off
@echo.删除结束!
@pause
三、关于SC
可参考一个网友的博文—SC命令管理服务状态:http://blog.csdn.net/ddjj_1980/article/details/7493045

© 版权声明
THE END
喜欢就支持一下吧
点赞0 分享