Skip to main content

Import Batch Class Using the API


Question / Problem: 

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

Answer / Solution: 

Here is a sample C# Console Application that imports Batch Classes in cab files listed on the command line as parameters. The parameters "file1,file2," etc., are full paths to the cab files. The application will import all Batch Classes in each cab file listed.

First, references must be added to:   Kofax.Capture.AdminModule.dll  and Kofax.KfxCollection.Interop.dll

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

namespace ImportBatchClasses
    class Program
        private static AdminLogin oAdminLogin = null;
        private static IAdminApplication oAdminApplication = null;       

        static void Main(string[] args)
            if (args.Length == 0)
                    Console.WriteLine("Logging into Kofax Capture...");
                    oAdminLogin = new AdminLogin();
                    oAdminLogin.Login("", "");
                    oAdminApplication = oAdminLogin.ActiveApplication;
                    KfxCollection batchClasses = new KfxCollection();

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

                    foreach (string f in files)
                        oAdminApplication.ImportBatchClasses(f,                 //Full path to cab file
                            batchClasses,                                       //Empty = Import all in Classes cab file
                            KfxApiTransferMode.KfxTransferModeRenameDuplicates, //Rename duplicates on import
                            true,                                               //True to import users/groups assignment
                            true,                                               //True to import user profiles 
                            KfxApiKCNSProfilesImportMode.KfxKCNSProfilesImportModeNotImported, //KCNS Profiles not imported
                            false);                                             //False to hide process dialog
                catch (Exception ex)
                    Console.WriteLine(ex.Message + "\n\n" + ex.StackTrace);
                    oAdminApplication = null;
                    if (oAdminLogin != null)





Applies to:  

Product Version
Kofax Capture 10.2, 11.x