Running AutoMassSecure™ from a Command-Line BAT File
Introduction
It is possible to run AutoMassSecure™ from outside of Adobe® Acrobat® via a command-line BAT file. Use this method to automate document securing by starting the processing from an another application or Windows Task Scheduler. This functionality is available in version 1.8 and up.
You would need to configure the AutoMassSecure™ settings using a regular method via user interface prior to running it via a BAT file. Settings need to be saved into a *.masssecure settings file.
Configure the Processing Settings
Use "Plug-ins > Secure Files..." menu to configure all necessary processing settings. See other available tutorials for details on how to configure and use AutoMassSecure. Test the processing settings in the regular user interface mode to make sure they are working correctly. Save ready-to-use settings into a *.masssecure file by clicking "Save Settings" button. This will create a settings file that contain all necessary parameters for the securing PDF files. The settings file defines how the files are going to be secured, where to place the resulting files and passwords.
Create a BAT File
Use any plain text editor (such as Notepad) to create a blank text file. Add the following lines to the file. Make sure to replace paths and filenames with the actual filenames you are using.
The example below shows how to start Acrobat DC and secure Test.pdf PDF file using the security settings from Settings.masssecure file.
SET AUTOMASSSECURE_INPUT_FILE=C:\Data\Test.pdf
SET AUTOMASSSECURE_CONFIG_FILE=C:\Data\Settings.masssecure
SET AUTOMASSSECURE_LOG_FILE=c:\data\AutoMassSecureLog.txt
"C:\Program Files (x86)\Adobe\Acrobat DC\Acrobat\Acrobat.exe" /n /h
The example below shows how to start Acrobat DC and secure all PDF files in C:\Data\Input folder using the security settings from Settings.masssecure file.
SET AUTOMASSSECURE_INPUT_FOLDER=C:\Data\Input
SET AUTOMASSSECURE_CONFIG_FILE=C:\Data\Settings.masssecure
SET AUTOMASSSECURE_LOG_FILE=c:\data\AutoMassSecureLog.txt
"C:\Program Files (x86)\Adobe\Acrobat DC\Acrobat\Acrobat.exe" /n /h
The environment variables are used to specify the input file or folder:
  • AUTOMASSSECURE_INPUT_FILE is used to specify a full file path to the PDF file that needs to be password-protected.
  • AUTOMASSSECURE_INPUT_FOLDER is used to specify a full path to a folder. All files in the folder will be password-protected.
  • AUTOMASSSECURE_CONFIG_FILE specifies a full file path to the *.masssecure settings file.
  • AUTOMASSSECURE_LOG_FILE is used to output a processing log file that can be used for troubleshooting.
Save a BAT File
Save the BAT file with *.bat file extension. Make sure to select a proper file filter in the "Save As" dialog in Notepad to avoid saving the file with a default *.txt file extension.
Run a BAT File
The processing job can be executed by double-clicking on the BAT file in Windows File Explorer window or by running it from another application.
Please note that the BAT file will open Adobe Acrobat and may display a progress bar during the processing. Use /h switch on the Acrobat's command line to optionally run Adobe Acrobat minimized:
Starting AutoMassSecure from a C# Application
Here is a sample C# code that shows how to launch AutoMassSecure from a .NET application and pass all necessary parameters via the environmental variables.
System.Diagnostics.Process firstProc = new System.Diagnostics.Process();
firstProc.StartInfo.FileName = @"C:\Program Files (x86)\Adobe\Acrobat DC\Acrobat\Acrobat.exe";
firstProc.EnableRaisingEvents = true;
firstProc.StartInfo.UseShellExecute = false;
firstProc.StartInfo.Arguments = @"/n /h"; // pass command-line parameters
firstProc.StartInfo.EnvironmentVariables.Add("AUTOMASSSECURE_INPUT_FILE", @"C:\Data\Test.pdf");
firstProc.StartInfo.EnvironmentVariables.Add("AUTOMASSSECURE_CONFIG_FILE", @"C:\Data\Settings.masssecure");
firstProc.Start();
Monitoring a Hot-Folder
It is possible to monitor a specific "hot-folder" and automatically secure all PDF files that are placed into it. Use the same technique as described in the following tutorial that explains how to monitor a folder and execute a BAT file with a Powershell script.