无法连接远程机器.. [英] unable to connect with remote machine..

查看:88
本文介绍了无法连接远程机器..的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

好吧,我写了一个小程序,它获取了远程机器的详细信息。我为此编写了以下代码。

静态void Main(string [] args)
{

string Username = null;
string Password = null;

ConnectionOptions ConOptions = new ConnectionOptions();
ManagementScope MgmtScope;
ManagementObjectSearcher Searcher;
ObjectQuery Query;
ManagementObject MgmtObject;
ManagementObjectCollection MgmtObjectCollection;


ConOptions.Username =" username";
ConOptions.Password =" password";
ConOptions.Authority =" ntlmdomain:localhost";



MgmtScope =新的ManagementScope("\\\\\TruKnox_11 \\root \\cimv2");
MgmtScope.Connect();

Query = new ObjectQuery(" SELECT * FROM Win32_OperatingSystem");
Searcher = new ManagementObjectSearcher(MgmtScope,Query);

MgmtObjectCollection = Searcher.Get();

foreach(MgmtObjectCollection中的ManagementObject M)
{Console Console.WriteLine(" System Name:{0}" + M [" CSName"]);
Console.WriteLine(" Free Physical Memory:{0}" + M [" FreePhysicalMemory"]);
Console.WriteLine(" Free)虚拟内存:{0}" + M [" FreeVirtualMemory"]);
}} Console.ReadLine();
}



问题在哪里。帮助我。

well,i write a small program which get the details of remote machine.i write the following code for this..

        static void Main(string[] args)
        {
           
            string Username=null;
            string Password=null;


            ConnectionOptions ConOptions=new ConnectionOptions();
            ManagementScope MgmtScope;
            ManagementObjectSearcher Searcher;
            ObjectQuery Query;
            ManagementObject MgmtObject;
            ManagementObjectCollection MgmtObjectCollection;
   
    
            ConOptions.Username = "username";
            ConOptions.Password = "password";
            ConOptions.Authority="ntlmdomain:localhost";
           


            MgmtScope = new ManagementScope("\\\\TruKnox_11\\root\\cimv2");
            MgmtScope.Connect();

            Query = new ObjectQuery("SELECT * FROM Win32_OperatingSystem");
            Searcher = new ManagementObjectSearcher(MgmtScope, Query);

            MgmtObjectCollection = Searcher.Get();

            foreach(ManagementObject M in MgmtObjectCollection)
            {
                Console.WriteLine("System Name : {0}" + M["CSName"]);
                Console.WriteLine("Free Physical Memory : {0}" + M["FreePhysicalMemory"]);
                Console.WriteLine("Free Virtual Memory : {0}" + M["FreeVirtualMemory"]);
            }
            Console.ReadLine();
        }


where is the problem .help me.

推荐答案

抱歉..我告诉你这个例外情况,以便你能轻松地帮助我。 。

System.UnauthorizedAccessException

{{"访问被拒绝。 (HRESULT异常:0x80070005(E_ACCESSDENIED))"}

sorry..i told u the exception so that u can give help me easily..

System.UnauthorizedAccessException

{"Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED))"}


这篇关于无法连接远程机器..的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆