Remote WMI connection

前端 未结 9 1849
心在旅途
心在旅途 2020-12-31 14:46

I want to connect to remote PC running Windows 7, from another PC using ManagementScope on a local network. On remote PC I\'ve created a new user account \"Samuel\" withou

9条回答
  •  南笙
    南笙 (楼主)
    2020-12-31 14:59

    Not sure if it is denied because the WMI engine isn't listening on the remote machine, or if you have other login/connection issues.

    Here's the code I used to connect to my remote machine, and it is working perfectly. Maybe it will help you:

    ConnectionOptions oConn = new ConnectionOptions();
    ManagementScope oScope = null;
    
    oConn.Username = txtLogin;
    oConn.Password = txtPassword;
    oConn.Authority = "ntlmdomain:" + txtDomain;
    
    oScope = new ManagementScope("\\\\" + txtHostName + "\\root\\CIMV2", oConn);
    
    oScope.Connect();
    

    If my domain/login/password trio are accepted, then Connect() will work. Otherwise, Connect() throws an exception. As long as the specified credentials have permission on that machine, you should be off and running.

提交回复
热议问题