<< Click to Display Table of Contents >> Navigation: Code Virtualizer > Protecting an application > Protecting through the command line |
Code Virtualizer 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 Code Virtualizer project file (.cv). To create this project file, you need to start the Code Virtualizer 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:
Virtualizer.exe /protect YourProjectFile.cv
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 do not have any blocks to protect.
4 Error in inserted block.
5 Fatal error while protecting file.
6 Cannot write protected file to disk.
7 PE file not compatible.
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
Code Virtualizer also allows you to load a project file into the user interface through the command line. To do this you have to invoke Code Virtualizer in the following way:
Virtualizer.exe YourProjectFile.cv
After this, the Code Virtualizer user interface will appear with all the information contained in your project file and will be 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:
Virtualizer.exe /protect YourProjectFile.cv /inputfile YourInputApplication.exe /outputfile YourProtectedApplication.exe
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 virtualizer.exe /protect YourProjectFile.cv
if %ERRORLEVEL%==0 goto 0 if %ERRORLEVEL%==1 goto 1 if %ERRORLEVEL%==2 goto 2 if %ERRORLEVEL%==3 goto 3 goto done
:0 echo Application protected successfully goto done
:1 echo ERROR: File already protected goto done
:2 echo ERROR: File to protect cannot be opened goto done
:3 echo ERROR: No blocks to protect found
:done |
Redirecting output to a file
To redirect the console output to a file, you have to use an extra parameter to avoid that Code Virtualizer 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 Code Virtualizer from within Visual Studio and you want to display the information in the Output Window in Visual Studio. Example:
Virtualizer.exe /protect YourProjectFile.cv /shareconsole > output.txt
Hide output information
To hide all output information displayed by Code Virtualizer you can use the /q parameter. Example:
Virtualizer.exe /q /protect YourProjectFile.cv
Checking if a file is already protected
You can check if an application has already been protected by Code Virtualizer using the /checkprotected parameter. Example:
Virtualizer.exe /checkprotected Myapplication.exe
If the application is protected, it will exit with Error Code = 0. If the application is not protected, it will exit with Error Code = 1.