0

我正在尝试访问远程机器,但它给出了一个错误。我尝试使用远程机器的 ip ping 以检查 PC 是否已连接,但它工作正常。但是当我在 cmd 提示符下尝试任务列表以访问远程机器时,它给出“RPC 不可用”。并且所有 PC 都通过 LAN 连接.

代码:

connOptions = new ConnectionOptions();
//   connOptions.Authority = "ntlmdomain:domain";
string MyComputerName = sName.ToString();
string machineName = MyComputerName;
connOptions.Username = machineName + "\\" + MyComputerName;
//  connOptions.Username = MyComputerName;
                    connOptions.Password = "";
                    if (MyComputerName.ToUpper() == Environment.MachineName.ToUpper())
                    {
                        // Create the management scope with given credentials
                        myScope = new ManagementScope(@"\ROOT\CIMV2", connOptions);

                    }

                   else { 
                     myScope = new ManagementScope(@"\\" + MyComputerName + @"\ROOT\CIMV2",connOptions);
                    myScope.Connect();
                    }


                }
                catch (SocketException ex3)
                {
                    Console.WriteLine("FormatException caught!!!");
                }
                catch (Exception ex4)
                {
                    Console.WriteLine("Exception caught!!!");

                }

myScope.Connect(); 给出“UNAuthorizedAccessException”

我是否需要在 web.config 文件中进行任何设置,或者我是否必须进行任何类型的设置才能使此代码正常工作?

4

0 回答 0