Skip to content

Protecting through the command line

Use Code Virtualizer from the command line to integrate protection into your build system.

First, create a Code Virtualizer project file (.cv) in the user interface and configure the required protection options. Then run:

Virtualizer.exe /protect YourProjectFile.cv

The process returns one of these exit codes:

  • 0: Protection completed successfully.

  • 1: The project file does not exist or is invalid.

  • 2: The input file cannot be opened.

  • 3: The input file contains no blocks to protect.

  • 4: An inserted block is invalid.

  • 5: A fatal error occurred while protecting the file.

  • 6: The protected file cannot be written to disk.

  • 7: The PE file is not compatible.

Note: On Windows XP, command-line protection displays information about each protection stage in the current console.

Load a project file from the command line

To open a project in the user interface, run:

Virtualizer.exe YourProjectFile.cv

The user interface opens with the settings stored in the project.

Protect a different application

You can override the input and output files stored in the project:

Virtualizer.exe /protect YourProjectFile.cv /inputfile YourInputApplication.exe /outputfile YourProtectedApplication.exe

Example of command line processing in a BAT file

The following BAT file protects an application and checks the returned exit code:

@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
if %ERRORLEVEL%==4 goto 4
if %ERRORLEVEL%==5 goto 5
if %ERRORLEVEL%==6 goto 6

goto done

:0
echo Application protected successfully
goto done

:1
echo ERROR: Project file does not exit
goto done

:2
echo ERROR: File to protect cannot be opened
goto done

:3
echo ERROR: No blocks to protect found

:4
echo ERROR: Error in inserted SecureEngine macros

:5
echo ERROR: Internal protection error

:6
echo ERROR: Cannot write protected file to disk

:done

Redirecting output to a file

Use /shareconsole before redirecting console output to a file. This option is also required to show Code Virtualizer output in the Visual Studio Output window:

Virtualizer.exe /protect YourProjectFile.cv /shareconsole > output.txt

Hide output information

Use /q to hide all output:

Virtualizer.exe /q /protect YourProjectFile.cv

Checking if a file is already protected

Use /checkprotected to determine whether an application is already protected:

Virtualizer.exe /checkprotected MyApplication.exe

The command returns 0 if the application is protected and 1 if it is not.