Themida can be used to protect your files through the command line in order to include the protection of your application on all of your build systems.
First you need to create a Themida project file (.tmd). To create this project file, you need to start the Themida user interface and set up the protection options that you want to include in your application. After that you can invoke the following command in the command line to protect your application:
Themida /protect YourProjectFile.tmd
One of the following codes will be returned:
0 Protection was successful.
1 Project file does not exist or invalid.
2 File to protect cannot be opened.
3 File already protected.
4 Error in inserted SecureEngine macros.
5 Fatal error while protecting file.
6 Cannot write protected file to disk.
7 Error while opening or reading the inserted Splash file.
8 Taggant certificate cannot be applied.
Note: When command line protection is invoked under Windows XP, you will be able to see information about each protection stage in the current console.
Load a project file from the command line
Themida also allows you to load a project file into the user interface through the command line. To do this you have to invoke Themida in the following way:
After this, Themida user interface will appear with all the information contained in your project file and is ready to protect your applications.
Protecting a different application from the one in a project file
You can specify a different input and output application from the one that is stored in your project file when protecting via command line. Example:
Themida /protect YourProjectFile.tmd /inputfile YourInputApplication.exe /outputfile YourProtectedApplication.exe
Protecting a different software from the one in a project file
You can specify a different software from the one that is stored in your project file when protecting via command line. Example:
Themida /protect YourProjectFile /software YourSoftware
Redirecting output to a file
To redirect the console output to a file, you have to use an extra parameter to avoid that Themida attaches itself to the current console and after that, you can use the common output redirection. The parameter to use is /shareconsole. This is also required when you are calling Themida from within Visual Studio and you want to display the information in the Output Window in Visual Studio. Example:
Themida.exe /protect YourProjectFile /shareconsole > output.txt
Protecting an application with a text project file
When you protect from the command line, Themida reads the internal database to retrieve the project information, software to protect, etc. That is, Themida depends on it's database (MySQL) in order to perform protection. The problem with this approach is that the embedded MySQL database can only be accessed by one instance at a time, so you cannot protect multiple applications concurrently (at least that you move Themida.exe and its database to different folders). To avoid this problem, you can export your Themida project file as a text (INI) file and use that text project file to perform protection.
To generate a text project file, you can go to the Project Manager in Themida (click on Open Project) and select the desired project and click on Export button.
To protect your application from a text project file, you just need to invoke Themida as follows (suppose that your text project file is called my_project.tm)
Themida /protect my_project.tm
Of course, you can also specify the above extra parameters (/inputfile and/or /outputfile) if you want to use different input/output file from the one in your project file.
Example of command line processing in a BAT file
The following example shows a BAT file that can be included in your build system to protect your applications through the command line:
start /w Themida /protect YourProjectFile.tmd
if errorlevel 3 goto 3
if errorlevel 2 goto 2
if errorlevel 1 goto 1
if errorlevel 0 goto 0
echo Application protected successfully
echo ERROR: File already protected
echo ERROR: File to protect cannot be opened
echo ERROR: An internal error occurred while protecting