Skip to main content
Kofax

Publish a Batch Class Using the API

3023583

Question / Problem: 

How do I publish a Batch Class programmatically using the Kofax Capture API?

Answer / Solution: 

Here is a sample C# Console Application that publishes Batch Classes listed as command line parameters. Each parameter is a string representing a Batch Class Name. 

First, add a reference to: Kofax.Capture.AdminModule.dll

using System;
using Kofax.Capture.AdminModule.InteropServices;

namespace PublishBatchClasses
{
    class Program
    {
        private static AdminLogin oAdminLogin = null;
        private static IAdminApplication oAdminApplication = null;
        static void Main(string[] args)
        {
            if (args.Length == 0)
            {
                Console.WriteLine("Usage:");
                Console.WriteLine("PublishBatchClasses Batch Class Name1, Batch Class Name 2,...");
            }
            else
            {
                try
                {
                    Console.WriteLine("Logging into Kofax Capture...");
                    oAdminLogin = new AdminLogin();
                    oAdminLogin.Login("", "");
                    oAdminApplication = oAdminLogin.ActiveApplication;

                    string[] files = args[0].Split(',');

                    foreach (string f in files)
                    {
                        oAdminApplication.BatchClasses[f].Publish();                        
                    }
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message + "\n\n" + ex.StackTrace);
                }
                finally
                {
                    oAdminApplication = null;
                    if (oAdminLogin != null)
                        oAdminLogin.Logout();
                }
            }
        }
    }
}

 

 

 

Applies to:  

Product Version
   

 

 

  • Was this article helpful?