废话不多说,看命令行更直接!
一、直接使用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
net stop test3
sc delete test3
(新建一个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
@echo.服务关闭 @echo off @net stop test3 @echo off @echo.关闭结束! @pause
@echo.服务删除 @echo off @sc delete test3 @echo off @echo.删除结束! @pause
可参考一个网友的博文---SC命令管理服务状态:http://blog.csdn.net/ddjj_1980/article/details/7493045