现在的位置: 首页 > 综合 > 正文

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

2013年08月05日 ⁄ 综合 ⁄ 共 839字 ⁄ 字号 评论关闭

废话不多说,看命令行更直接!

一、直接使用cmd来进行服务的一些操作

1、安装服务

sc create test3 binPath= "C:\Users\Administrator\Desktop\win32srvDemo\win32srvdemo\Debug\win32srvDemo.exe"

其中:test3为创建的服务名,binPath后面是运行exe文件的所在路径

2、配置服务

有以下集中方式:

sc config 服务名 start=AUTO    (自动)

sc config 服务名 start= DEMAND  (手动)

sc config 服务名 start= DISABLED(禁用)

例如下面的命令,在XP系统中开机便会自动启动:

sc config test3 start= AUTO

3、开启服务

net start test3

4、关闭服务

net stop test3

5、删除服务

sc delete test3

二、为方便使用,可编辑为bat批处理文件

(新建一个txt文件,自己命名,把后缀改为.bat文件)

1、创建、配置、开启服务

@echo.服务启动......
@echo off
@sc create test3 binPath= "C:\Users\Administrator\Desktop\win32srvdemo\win32srvdemo\Debug\win32srvdemo.exe"
@net start test3
@sc config test3 start= AUTO
@echo off
@echo.启动完毕!
@pause

2、关闭服务

@echo.服务关闭
@echo off
@net stop test3
@echo off
@echo.关闭结束!
@pause

3、删除服务

@echo.服务删除
@echo off
@sc delete test3
@echo off
@echo.删除结束!
@pause

三、关于SC

可参考一个网友的博文---SC命令管理服务状态:http://blog.csdn.net/ddjj_1980/article/details/7493045

抱歉!评论已关闭.