我想控制(启动和停止)远程机器中的 Windows 服务。我可以连接那台机器,但我无法访问 Windows 服务。这是我的代码。你能帮助我吗?
ConnectionOptions oConn = new ConnectionOptions();
oConn.Username = "****";
oConn.Password = "****";
ManagementScope managementScope = new ManagementScope(@"\\***.***.***.***\root\CIMV2", oConn);
managementScope.Connect();
RelatedObjectQuery roq = new RelatedObjectQuery("Win32_Service.Name='KanAktarim'");
ManagementObjectSearcher moSearcher = new ManagementObjectSearcher(managementScope, roq);
ManagementObjectCollection mbCollection = moSearcher.Get();