0
任何人都知道如何找到範圍?
微軟說如何查找ManagementScope的範圍?
ManagementScope scope = new ManagementScope("\\\\FullComputerName\\root\\cimv2");
我在本地主機工作。 我已經測試過「\\ HOSTNAME \ root \ cimv2」和「\\ HOSTNAME \ MY_ACCOUNT_NAME \ cimv2」,但它們不起作用。
我在Windows 7專業版,我使用Visual Studio 2010和它的.Net 4
#更新1
int i = Convert.ToInt32(processIds[index]);
String queryString = "select CreationDate from Win32_Process where ProcessId='" + processIds[index] + "'";
SelectQuery query = new SelectQuery(queryString);
ManagementScope scope = new System.Management.ManagementScope("\\\\XXX-PC\\YYY\\cimv2");
ManagementObjectSearcher searcher = new ManagementObjectSearcher(scope, query);
ManagementObjectCollection processes = searcher.Get();
@keyboardP:Searcher.Get()工作異常,所以我認爲我的範圍不對。
是否有任何錯誤消息? – keyboardP 2011-06-03 02:15:27
主題中的更多信息 – 2011-06-03 02:20:53
我的猜測是你得到了「拒絕訪問」異常。嘗試添加'ConnectionOptions選項= 新的ConnectionOptions(); options.Authentication = System.Management.AuthenticationLevel.PacketPrivacy;'範圍之前。 – keyboardP 2011-06-03 02:24:34