ManagementPath path  = new ManagementPath(strComputerName+"\\root\\CIMV2");
                ConnectionOptions connection = new ConnectionOptions();
                connection.Username = strUser;
                connection.Password = strPwd;
                ManagementScope scope = new ManagementScope(path, connection);
                scope.Connect();连接一直报异常  说存取错误

解决方案 »

  1.   

    检查权限
    ConnectionOptions connection_wmi = new ConnectionOptions();
    connection_wmi.Username = "administrator";
    connection_wmi.Password = "";
    connection_wmi.Authority = "";ManagementScope scope = new ManagementScope("", connection_wmi);
    scope.Connect();
      

  2.   

    我在网上找到的 设了 没有用:
      Run dcomcnfg command (via Start menu -> Run dialog) to bring up Component Services window. 
    Expand nodes: Component Services -> Computers -> My Computer > DCOM Config 
    Scroll down list, right-click Windows Management and Instrumentation, and select Properties, then "Management and Instrumentation Properties" window will be displayed. 
    Select the Security tab, then select "Customize" radio button to activate the Edit button, then you will see such two permission options ("Local Access" , "Remote Access") for each account. 
    Add the ASPNET account, and assign the "Remote Access" permission.    
    Reboot the server.