Issue With silent printing to Adobe Reader DC in c# via Windows Task Scheduler

Ask A Question

Login To post a question

I am trying to print pdf documents from a console program in C# that I need to automate. It works fine if I run it manually, but if I use the Windows 10 Task Scheduler, it does not work. I see Adobe Reader launched in Task Manager but it does not print out or attempt to print. No errors occur, it just opens adobe then closes it 10 seconds later as it supposed too. It is not the size of the files as it all works perfectly if executed directly on the desktop. It used to work fine, but appears to have stopped working since the Feature Update to Windows 10, version 1803 is installed, although it could also be a Adobe Reader update I guess. When it used to work the Adobe window used to come up on the screen and disappear (which was not a problem), and now since these updates everything is completely hidden, but it is launching! It’s impossible to debug obviously as it’s only in Task Scheduler, and it looks like it’s working apart from the actual printing bit.

The c# code is pretty much the standard way of printing to Adobe:

public static Boolean PrintPDFs(string pdfFileName)
            Process proc = new Process();
            proc.StartInfo.WindowStyle = ProcessWindowStyle.Normal;
            proc.StartInfo.Verb = "print";

            proc.StartInfo.FileName = System.Configuration.ConfigurationManager.AppSettings["Adobe_Path"];
            proc.StartInfo.Arguments = String.Format(@"/o /p /h ""{0}""", pdfFileName);
            proc.StartInfo.UseShellExecute = false;
            proc.StartInfo.CreateNoWindow = false;
            proc.EnableRaisingEvents = true;
            if (proc.HasExited == false)
            //Abobe sometimes hangs around so we kill it!
            return true;
        catch (Exception ex)
            return false;

Anyone have any ideas of how to get this working when scheduled under Task Scheduler? I am running Task Scheduler in an Administrator User Account with Highest privileges.



For more info please click here

Have a question or need a custom quote?