Windows Service won't stop/start
<p>I'm using the following code fragment to stop a service. However, both the Console.Writeline statements indicate the service is running. Why won't the service stop?</p>

<pre><code>class Program
    {
        static void Main(string[] args)
        {
            string serviceName = "DummyService";
            string username = ".\\Service_Test2";
            string password = "Password1";

            ServiceController sc = new ServiceController(serviceName);

            Console.WriteLine(sc.Status.ToString());

            if (sc.Status == ServiceControllerStatus.Running)
            {
                sc.Stop();
            }

            Console.WriteLine(sc.Status.ToString());
</code></pre>
