private void connSer(string User,string Pass,string Server)
        {
            
            ConnectionOptions options = new ConnectionOptions();
            Console.WriteLine("fffffffffff0fffffffffffff");
            options.Username = "administrator";   //could   be   in   domain\user   format   
            Console.WriteLine("fffffffffff1fffffffffffff");
            options.Password= "xingxinde";
            Console.WriteLine("fffffffffff2fffffffffffff");
            Console.WriteLine(Server);
            Console.WriteLine(Pass);
            ManagementScope scope = new ManagementScope("\\\\\miss\\rising$\\rav", options);
            Console.WriteLine("fffffffffff3ffffffffffffff");
            
           
            try
            {
                scope.Connect();
                //ManagementObject disk = new ManagementObject(scope,new ManagementPath("Win32_logicaldisk=Server"),null);
                //disk.Get();
            }
            catch (Exception e)
            {
                Console.WriteLine("ffffffffffffffffffffffff");
            }
        }***************************
 ManagementScope scope = new ManagementScope("\\\\\miss\\rising$\\rav", options);
运行到上面这句提示“参数无效”

解决方案 »

  1.   

    private void connSer(string User,string Pass,string Server) 
            { 
                
                ConnectionOptions options = new ConnectionOptions(); 
                Console.WriteLine("fffffffffff0fffffffffffff"); 
                options.Username = "administrator";  //could  be  in  domain\user  format  
                Console.WriteLine("fffffffffff1fffffffffffff"); 
                options.Password= "xingxinde"; 
                Console.WriteLine("fffffffffff2fffffffffffff"); 
                Console.WriteLine(Server); 
                Console.WriteLine(Pass); 
                ManagementScope scope = new ManagementScope(@"\\\\\miss\\rising$\\rav", options); 
                
    Console.WriteLine("fffffffffff3ffffffffffffff"); 
                
              
                try 
                { 
                    scope.Connect(); 
                    //ManagementObject disk = new ManagementObject(scope,new ManagementPath("Win32_logicaldisk=Server"),null); 
                    //disk.Get(); 
                } 
                catch (Exception e) 
                { 
                    Console.WriteLine("ffffffffffffffffffffffff"); 
                } 
            } 如果加上@也不成的话 那就是参数有问题
      

  2.   

    ManagementScope scope = new ManagementScope(@"\\miss\rising$\rav", options); 
      

  3.   

    我试了
    @"\\miss\rising$\rav"和“\\\\miss\rising$\rav”多不行 
      

  4.   

     // Build an options object for the remote connection
                // if you plan to connect to the remote
                // computer with a different user name
                // and password than the one you are currently using.
                // This example uses the default values.             ConnectionOptions options =
                    new ConnectionOptions();            // Make a connection to a remote computer.
                // Replace the "FullComputerName" section of the
                // string "\\\\FullComputerName\\root\\cimv2" with
                // the full computer name or IP address of the
                // remote computer.
                ManagementScope scope =
                    new ManagementScope(
                    "\\\\FullComputerName\\root\\cimv2", options);
                scope.Connect();            //Query system for Operating System information
                ObjectQuery query = new ObjectQuery(
                    "SELECT * FROM Win32_OperatingSystem");
                ManagementObjectSearcher searcher =
                    new ManagementObjectSearcher(scope, query);            ManagementObjectCollection queryCollection = searcher.Get();
                foreach (ManagementObject m in queryCollection)
                {
                    // Display the remote computer information
                    Console.WriteLine("Computer Name : {0}",
                        m["csname"]);
                    Console.WriteLine("Windows Directory : {0}",
                        m["WindowsDirectory"]);
                    Console.WriteLine("Operating System: {0}",
                        m["Caption"]);
                    Console.WriteLine("Version: {0}", m["Version"]);
                    Console.WriteLine("Manufacturer : {0}",
                        m["Manufacturer"]);
                }