title: Printing PDFs in WinServer 2008 from a non-interactive process (Windows service, scheduled task, etc.)
body: <p>I am trying to write a non-interactive process that prints PDFs, and I need advice on how to build this on Windows Server 2008 (and Vista/7).</p>
  
  <p>Previously, we have had a scheduled task (set to run whether the user account was logged on or not) that would print all PDFs inside of a directory. (A seperate process would move the PDFs into the directory.) At runtime, this would spin up another process (either Adobe Reader or Foxit Reader) to print the PDF. Both Adobe Reader and Foxit Reader feature silent printing, so everything would be sent to the default printer for the user that the scheduled task ran as. No UI was ever generated, and all files would be printed without a hitch. <strong>This worked on Server 2003.</strong></p>
  
  <p><strong>The process no longer works on Server 2008.</strong> I'm not entirely sure, but I believe this has to do with Session 0 Isolation. I cannot prove this. However, I can say that <strong>the process works as a scheduled task when set as "Run only when the user is logged in"</strong>. Now, while this works, it forces a user to log in to the machine, and thus does not fulfill my requirements. (My first clue was in <a href="https://stackoverflow.com/questions/5596394/how-to-print-pdf-document-from-windows-service">this previous question</a>.)</p>
  
  <p>I cannot determine how I can move forward on this. Is there any way to fulfill my requirements?</p>
  
  <p>A few notes :</p>
  
  <p><strong>Every solution I've seen seems to be using the credentials of a logged-in user.</strong> See the question I linked above - the solution listed appears to be grabbing the token of a logged-in user and using it to run the program. (Look at the GetCurrentUserToken() procedure - the returned value is later used in the API call CreateProcessAsUser().)</p>
  
  <p><strong>My current process generates, as near as I can tell, no UI.</strong> I've verified, using ProcMon, that the reader process (Adobe or Foxit) appears to print correctly and the print driver itself appears to have a problem. This is backed up by an attempt to use a print-to-file driver - the print-to-file driver runs in three visible steps and clearly finishes the first for all files without starting the second. So how does Session 0 Isolation affect the printer driver? This is unclear to me. (<a href="http://msdn.microsoft.com/en-us/windows/hardware/gg463353.aspx" rel="nofollow noreferrer">The best documentation I can find on the subject</a> only mentions that printer drivers may be affected, even though the print spooler runs in Session 0.) </p>
  
  <p>Printing as a Windows service never works, even when the process has 'Allow service to interact with desktop' checked.</p>
  
  <p>Bold text added to counter the blear-inducing wall-of-text effect.</p>