I tried to start/stop window service of VPN remote server, but no luck.
Now I can start/stop window server of remote server on same domain with my PC, as describe in Start A Remote Service From C# .
我尝试采用这种办法:。 http://www.eggheadcafe.com/ community/csharp/2/15950/windows-services-remote-organne.aspx,但是在获得东道国名时,它 throw下了WSANO_DATA - 11004 (行文:
String HostName = Dns.GetHostEntry (Server)。 HostName;
。
此处的样本代码(NET 4.0)
ConnectionOptions cred = new ConnectionOptions();
cred.Username = _UsrNm;
cred.Password = _Pass;
String hostName = Dns.GetHostEntry(_Server).HostName;
ManagementScope srvScope;
srvScope = new ManagementScope(string.Format("\\{0}\root\cimv2", hostName), cred);
ManagementPath win32Path = new ManagementPath("Win32_Service");
ManagementClass services;
services = new ManagementClass(srvScope, win32Path, null);
请向我提出任何建议或意见。
Tks.