<< Click to Display Table of Contents >> Navigation: WinLicense > Protecting an application > Protecting through the command line |
WinLicense 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 WinLicense project from the user interface. To create this project file, you need to start the WinLicense 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:
WinLicense /protect YourProject
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 Internal protection error.
6 Cannot write protected file to disk.
7 Error while opening or reading the inserted Splash file.
Load a project file from the command line
WinLicense also allows you to load a project into the user interface through the command line. To do this you have to invoke WinLicense in the following way:
WinLicense YourProject
After this, WinLicense 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:
WinLicense /protect YourProjectFile /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:
WinLicense /protect YourProjectFile /software YourSoftware
Protect several projects in parallel
If you want to protect several projects in parallel, you have to pass the "/isolate" command line parameter. The /isolate parameter will serialize accesses to the WinLicense MySQL database in order to read the specific project settings for each project that is going to be protected in parallel. Example:
WinLicense /protect YourProjectFile1 /isolate
WinLicense /protect YourProjectFile2 /isolate
Redirecting output to a file
To redirect the console output to a file, you have to use an extra parameter to avoid that WinLicense 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 WinLicense from within Visual Studio and you want to display the information in the Output Window in Visual Studio. Example:
WinLicense.exe /protect YourProjectFile /shareconsole > output.txt
Protecting an application with a text project file
When you protect from the command line, WinLicense reads the internal database to retrieve the project information, software to protect, etc. That is, WinLicense depends on it's database (MySQL) in order to perform protection. If you don't want to rely on the WinLicense database in protection time, you can export your WinLicense 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 WinLicense (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 WinLicense as follows (suppose that your text project file is called my_project.wl)
WinLicense /protect my_project.wl
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.
Opening the License Manager without the WinLicense GUI
If you just want work with the License Manager and don't want to display the main WinLicense user interface, you can use the /licensemanager parameter when launching WinLicense. Example:
WinLicense /licensemanager
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:
@echo off
start /w WinLicense /protect YourProject
if errorlevel 6 goto 6 if errorlevel 5 goto 5 if errorlevel 4 goto 4 if errorlevel 3 goto 3 if errorlevel 2 goto 2 if errorlevel 1 goto 1 if errorlevel 0 goto 0 goto done
:0 echo Application protected successfully goto done
:1 echo ERROR: Project file does not exist goto done
:2 echo ERROR: File to protect cannot be opened goto done
:3 echo ERROR: File is already protected
:4 echo ERROR: Error in inserted SecureEngine macros
:5 echo ERROR: Internal protection error
:6 echo ERROR: Cannot write protected file to disk
:done |