title: Renaming a computer Invalid Method Parameters C#
body: <p>Why does this work:</p>
  
  <pre><code>using System;
  using System.Management;
  
  public class InvokeMethod
  {
      public static void Main()
      {
          ManagementClass processClass = new ManagementClass("Win32_Process");
          ManagementBaseObject inParams = processClass.GetMethodParameters("Create");
          inParams["CommandLine"] = "calc.exe";
          InvokeMethodOptions methodOptions = new InvokeMethodOptions(null, System.TimeSpan.MaxValue);
          ManagementBaseObject outParams = processClass.InvokeMethod("Create", inParams, methodOptions);
      }
  }
  </code></pre>
  
  <p>And this NOT work:</p>
  
  <pre><code>using System;
  using System.Management;
  public class Program
  {
      public static void Main()
      {
          ManagementClass rename = new ManagementClass("Win32_ComputerSystem");
          ManagementBaseObject inParams = rename.GetMethodParameters("Rename");
          inParams.SetPropertyValue("Name", "Name1234");
          InvokeMethodOptions methodOptions = new InvokeMethodOptions(null, System.TimeSpan.MaxValue);
          ManagementBaseObject outParams = rename.InvokeMethod("Rename", inParams, methodOptions);
          Console.Read();
      }
  }
  </code></pre>
  
  <p>The problem here is this line:</p>
  
  <pre><code>ManagementBaseObject outParams = rename.InvokeMethod("Rename", inParams, methodOptions);
  </code></pre>
  
  <p>Invalid Method Parameters.
  I understand you have to run it as administrator as is for it to do anything but I just want it to work.</p>