當使用WMI :
ConnectionOptions connectionOptions = new ConnectionOptions(); connectionOptions.Username = userName; connectionOptions.Password = password; ManagementScope managementScope = new ManagementScope("\\\\" + host + "\\root\\cimv2", connectionOptions); try { managementScope.Connect(); } catch { }
發生"RPC 服務器不可用"或者其它無法連接的情況下(確保連接本機沒有問題)的解決方案:
1 檢查遠程服務器 “Remote Procedure Call”、“DCOM Server Process Launcher” 和 “DHCP Client”服務 是否開啟
2 檢查遠程服務器 本地安全策略--本地策略--安全選項--網絡訪問:本地帳戶的共享和安全模式--屬性 選擇:經典-本地用戶以自己的身份驗證
3 在遠程服務器上,運行"netsh firewall set service RemoteAdmin".