我正在使用以下代碼片段來停止服務。但是,Console.Writeline
聲明表明服務正在運行。爲什麼服務不會停止?Windows服務不會停止/啓動
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());
}
}
在哪裏使用的用戶名和密碼? – Aliostad 2010-10-25 15:47:46
我在更改與服務關聯的帳戶和密碼的代碼中進一步使用它。 – xbonez 2010-10-25 15:50:01