The PC Guard software protection suite features a robust command line interface (CLI) designed to fully automate the application protection process. By invoking the PC Guard executable with specific parameters, developers can integrate protection into build scripts, batch files, and other automated workflows. The core functionality is triggered by the -PROCESS
option, which applies the settings from a specified project file. For unattended execution, a -SILENT
mode is available, which suppresses all messages and prompts.
The CLI allows for granular control by enabling the override of nearly any setting within a project file directly from the command line. This includes fundamental parameters such as application filenames and output paths, as well as detailed settings for user information, custom counters, password protection, and serial number generation. Crucially, the CLI provides feedback through standard Windows errorlevel
codes, returning 0
for a successful operation and a non-zero error code upon failure. This feature is essential for scripting, allowing for reliable error detection and handling within automated processes.
1. Core Functionality and Syntax
The primary purpose of the PC Guard command line interface is to enable the automated, scripted protection of software applications. This eliminates the need for manual interaction with the graphical user interface, making it ideal for integration into continuous integration and delivery (CI/CD) pipelines or other build systems.
1.1 General Syntax
The basic structure for executing PC Guard from the command line is as follows:
<full path to PC Guard> <options> <project filename>
<full path to PC Guard>
: The complete path to thepcguard.exe
executable (e.g.,"C:\Program Files (x86)\PC Guard for Win32\pcguard.exe"
).<options>
: One or more command line switches that control the process and override project settings.<project filename>
: The path to the PC Guard project file (.prj
) containing the protection settings.
1.2 Essential Process Control
Three primary options govern the execution of the protection process:
-PROCESS
: This is the key option that instructs PC Guard to automatically process the project file submitted from the command line.-SILENT
: When used, this option prevents PC Guard from displaying any informational messages, prompts, or confirmations. It is recommended to thoroughly test the protection process before enabling this switch.-SAVE
: If this option is included, the project settings will be saved after the protection process is complete.
1.3 Error Handling
PC Guard communicates its execution status back to the command processor via errorlevel
codes, enabling script-based error handling.
errorlevel 0
: Indicates that the protection process completed successfully.errorlevel [Standard Windows error code]
: A non-zero value indicates that an error occurred during the process.
2. Comprehensive Command Line Parameters
The CLI provides an extensive set of parameters that can be used to overwrite the corresponding settings stored within a project file. Any parameter containing spaces must be enclosed in double quotes ("
).
Parameter | Description |
Project & File Management | |
-FILE [Application filename] | Specifies the application filename to be protected. |
-OUTPUT [Output filename] | Defines the filename for the protected output application. |
-BACKUP [Backup filename] | Sets the filename for the backup of the original application. |
-REPORT [Report filename] | Defines the filename for the protection report. |
-SKIPAP | Skips applications that have already been protected. |
Application Identification | |
-PROGID [Program ID] | Sets the Program ID value. |
-APPNAME [Application name] | Sets the application name. |
-APPSIGN [Application signature] | Sets the application signature. |
-UPDATEID | Sets the application update ID value. |
Security & Licensing | |
-PASSWORD [Password] | Specifies the password for the password protection feature. |
-ACENPWD [Password] | Sets the ACEN (Activation Center) server password for web licensing. |
User Information | |
-UNAME [User name] | Sets the user name. |
-UADDRESS [User address] | Sets the user address. |
-UCOMPANY [User company] | Sets the user company. |
-UINFO1 [User info 1] | Sets custom user information field 1. |
-UINFO2 [User info 2] | Sets custom user information field 2. |
-UINFO3 [User info 3] | Sets custom user information field 3. |
Custom Counters | |
-CC1 [Counter] to -CC10 [Counter] | Sets values for custom counters 1 through 10. |
Serial Number Generation | |
-SNGEN | Triggers the generation of serial numbers from the command line. |
-SNSEED [Seed] | Specifies the seed value for serial number generation. |
-SNFILE [Output filename] | Defines the output filename for the generated serial numbers. |
-SNFIRST [ID] | Sets the ID of the first serial number to generate. |
-SNLAST [ID] | Sets the ID of the last serial number to generate. |
Configuration | |
-LANG [Language] | Defines the project language. |
3. Practical Implementation: Using Batch Files
Batch files are a powerful method for automating the protection of multiple applications, such as a main executable and its associated libraries or modules. The ability to check the errorlevel
after each step allows for the creation of robust and reliable scripts.
3.1 Example Batch File
The following example demonstrates a batch script that protects a main application (test.exe
) and a DLL module (test.dll
) using two separate project files. It includes basic error checking.
@echo off
set PCGUARD="C:\Program Files (x86)\PC Guard for Win32\pcguard.exe"
rem c:\test\test.exe is protected and output file c:\output\test.exe is created
%PCGUARD% -process -file c:\test\test.exe -output c:\output\test.exe "c:\my projects\example1.prj"
rem c:\test\test.dll is protected and output file c:\output\test.dll is created
%PCGUARD% -process -file c:\test\test.dll -output c:\output\test.dll "c:\my projects\example2.prj"
if errorlevel 1 goto protection_error
echo Protection OK!
goto end
:protection_error
echo Problems detected!
:end
3.2 Key Best Practices
- Test Before Silencing: Always test the complete protection process from the command line without the
-SILENT
switch to ensure all parameters are correct and the process works as expected. Once confirmed, the-SILENT
option can be added for unattended execution. - Parameter Precedence: Remember that any parameter specified on the command line will overwrite the corresponding setting within the referenced project file for that specific execution.
- Use Error Checking: Leverage the
errorlevel
return code in scripts to verify the success of each protection step and handle failures appropriately.