title: Adding network printers via C#
body: <p>I want to add Network Printers to a Windows user account via C#.
  I am using the following code to do this:</p>
  
  <pre><code>public bool AddPrinter(string printer)
  {
      var managementScope = new ManagementScope(ManagementPath.DefaultPath);
      managementScope.Connect();
  
      var printerClass = new ManagementClass(new ManagementPath("Win32_Printer"), null);
      var inputParameters = printerClass.GetMethodParameters("AddPrinterConnection");
  
      inputParameters.SetPropertyValue("Name", printer);
  
      var managementBaseObject = printerClass.InvokeMethod("AddPrinterConnection", inputParameters, null);
  
      if (managementBaseObject != null &amp;&amp; Convert.ToInt32(managementBaseObject["ReturnValue"]) == 0)
      {
          return true;
      }
  
      return false;
  }
  </code></pre>
  
  <p>As the Parameter I am using the UNC path of the Printer.
  This works so far. I have now got the problem that when using the printer the name of the printer is the UNC path of the printer. In some applications people just see the beginning of the path.</p>
  
  <p>e.g.:</p>
  
  <p>\myprinters.domain.intra...</p>
  
  <p>\myprinters.domain.intra...</p>
  
  <p>\myprinters.domain.intra...</p>
  
  <p>This way they cannot see which printer to select. </p>
  
  <p>How can I use a different name when adding the Network Printer?</p>