tags:

views:

46

answers:

2

I have 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 ?

+1  A: 

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)".

Hans Passant
"SQL Server (SQLEXPRESS)" is a display name and is different to the actual service name, but net start will enumerate it though
gbn
A: 

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#

gbn