开发者

stop SQL service in c#

I hav开发者_高级运维e installed 2 servers for Microsoft SQL 2008. The first one is MSSQLSERVER and second one is SQL2008. When I tried to stop the first one it stopped but the second one not the VS told me that this service not found

ServiceController svc =
    new ServiceController("SQL2008", Process.GetCurrentProcess().MachineName);
svc.Stop()

So, how can I stop the second one also ?


At the command prompt, type NET START to get a list of running services. The name you see listed is what you should pass as the first argument. A example name would be "SQL Server (SQLEXPRESS)".


I can't access a SQL box just now but the service name is something like mssqlserver$2008 IIRC

If you find the service in services.msc, double click, it's the top label/entry. This is the actual servicename in the registry (HKLM) and would respond to net start etc. It's different to the display name.

Hopefully it's the same for c#

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜