首页 新闻 会员 周边

vs开关sql服务

1
[已解决问题] 解决于 2011-05-24 10:48

用C#制作一个开关sql服务的winform程序。。。。

丶Pp的主页 丶Pp | 初学一级 | 园豆:180
提问于:2010-12-20 15:32
< >
分享
最佳答案
0

自己写的一个bat。查c#执行批处理的方法。

@echo off
color 0B
::判断服务是否被禁用,如果被禁用就设置为自动...
::wmic service where "name="MSSQL$ASTAR7" and startmode="disabled"" call changestartmode
::判断服务是否启动,如果未启动就启动此服务...
::wmic service where "name="MSSQL$ASTAR7" and state="stopped"" call startservice
net start >d:\service.txt
find /i d:\service.txt "SQL Server (ASTAR7)"
if errorlevel 1 goto start
if errorlevel 0 goto stop
:start
net start MSSQL$ASTAR7
goto success
:stop
net stop MSSQL$ASTAR7
goto end
:success
::net start
@echo 服务开启成功...
:end
del "d:\service.txt"

Astar | 高人七级 |园豆:40805 | 2010-12-20 16:18
不好一可能是我没说明白。。我想要一个winform或者。net的程序来开关slq服务。。。我想知道winform来开关本机服务继承自那个类。。
丶Pp | 园豆:180 (初学一级) | 2011-01-02 19:03
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册