title: ghostscript command line arguments printer selection in ps file
body: <p>I am using a c# wrapper to batch print pdf files without user interaction. I am using a ps file which is created dynamically by c# wrapper and Iprovide that ps file as process start args. The reason for use a ps file is gs does not support dynamic user friendly spooler name as command line args. he problem is gs does not automatically select the printer when I am using ps file. It always asks to select printer manually. here is the code</p>
  
  <pre><code>class Program
  {
      static void Main(string[] args)
      {
  
  
          try
          {
              string path = Application.StartupPath + "\\wd.print";
              StreamReader sr = new StreamReader(path);
              string[] content = sr.ReadToEnd().Split(new char[] { '\n', '\r' }, StringSplitOptions.RemoveEmptyEntries);
              sr.Close();
  
              string printer = content[0];
  
              for (int i = 1; i &lt; content.Length; ++i)
              {
                  ProcessStartInfo psInfo = new ProcessStartInfo();
  
  
                  psInfo.Arguments = String.Format(" setup.ps -dPrinted -dBATCH -dNOPAUSE -dNOSAFER -q -dNumCopies=1 -sOutputFile=\"\\\\spool\\{0}\" \"{1}\"",
                     printer,
                     content[i]);
  
  
                  String spoolerName = content[i].Substring(content[i].IndexOf("$")+1);
                  //creates the dynamic ps file named setup.ps
                  generateSettings(spoolerName);
                  string gs = Application.StartupPath + @"\gs\gswin32c.exe"; ;
                  psInfo.FileName = gs;
                  psInfo.UseShellExecute = false;
                  Process process = Process.Start(psInfo);
                  process.WaitForExit();
                  Console.ReadLine();
              }
  
          }
          catch (Exception ex)
          {
              MessageBox.Show(ex.Message);
              Console.Write(ex.Message);
              Console.ReadLine();
          }
      }
      protected static void generateSettings(String name)
      {
          //the code which creates the dynamic ps file named setup.ps
          FileStream file=File.Create("setup.ps");
          StreamWriter writer = new StreamWriter(file);
          writer.WriteLine("mark");
          writer.WriteLine("  /NoCancel true ");
          writer.WriteLine("  /UserSettings");
          writer.WriteLine("   &lt;&lt;");
          writer.WriteLine("    /DocumentName (" + name + ")");//custom name for windows print spooler
          writer.WriteLine("   &gt;&gt;"); 
          writer.WriteLine("  (mswinpr2) finddevice");
          writer.WriteLine("  putdeviceprops");
          writer.WriteLine("setdevice");
  
          writer.Flush();
          writer.Close();
          file.Close();
  
  
  
  
      }
  }
  </code></pre>
  
  <p>please help me . I want to select the printer automatically so it does not want user intervention</p>