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

2,951次阅读
没有评论

一、直接使用 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

正文完
 0
评论(没有评论)
验证码