Home Issue With silent printing to Adobe Reader DC in c# via Windows Task Scheduler
Reply: 0

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

user2288
1#
user2288 Published in May 27, 2018, 3:38 am

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)
    {
        try
        {
            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;
            proc.Start();
            if (proc.HasExited == false)
            {
                proc.WaitForExit(10000);
            }
            proc.Close();
            //Abobe sometimes hangs around so we kill it!
            KillAdobe("AcroRd32");
            return true;
        }
        catch (Exception ex)
        {
            Log.WriteLog(ex.Message);
            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.

Thanks

Dave

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.305189 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO