Setting the subscription key from the command line
Posted by Finnbogi Finnbogason on 24/07/2014 11:18

In this FAQ entry we introduce a little helper script to set the subscription key. Since it is based solely on features supported by the NT script processor, you can easily use this in AD group policies or similar.

The problem
You want to set the subscription key along with an unattended deployment of FPAV throughout, for example, an Active Directory.

The script

@echo off
@if "%OS%"=="Windows_NT" goto :MAIN
@echo This script requires Windows 2000 or later to run properly!
goto :EOF
:: Provided to you by FRISK Software International
:: Script to enter the subscription key into the registry.
:: We hope that the script is valuable to you. Your use of the script, however,
:: is at your sole risk. The script is provided "AS-IS", without any warranty!
:: LAST CHANGE: 2008-07-22
::   setkey.cmd THE-KEY
:: Note: the key *can* contain dashes.
:: Requires: FPAV for Windows or higher and REGEDIT.
set SUBKEY=%1
if "%SUBKEY%" == "" echo You have to give the subscription key as first parameter & exit /b 255
set REGFILE=%TEMP%\fpavkey.reg
echo ^[HKEY_LOCAL_MACHINE\SOFTWARE\FRISK Software\F-PROT Antivirus for Windows^] >> "%REGFILE%"
echo ^"LicenseKey^"=^"%SUBKEY%^" >> "%REGFILE%"
regedit /s "%REGFILE%"
exit /b 0

The simplest version is:

setkey.cmd THE-KEY

However, you may want to check for success. This, however requires a little more work. The NT script processor will consider the calling of the script itself as successful, so the following does not what you'd expect it to do if the script fails to set the key:

setkey.cmd THE-KEY || echo Failed to set key. What to do?

... instead you'll have to be a little more explicit by saying:

call setkey.cmd THE-KEY || echo Failed to set key. What to do?

... which will yield the expected result.

If you have F-PROT already installed, you may want to restart the F-PROT dispatcher service by giving a:

net stop FPAVServer && net start FPAVServer

If, however, you do this before installation, all will be fine without further action.

How does it work?
Very simple. It takes as its only command line argument the subscription key, removes all dashes from it and then sets it in the registry.

If your needs are slightly different and you'd like to deploy the script, but hard-code the subscription line, just change this line:

set SUBKEY=%1

to read


Obviously you'll have to give a valid key in place of THE-KEY.

You need F-PROT Antivirus for Windows or higher as well as REGEDIT. Furthermore you need to run the script under an account that has the necessary rights to modify HKEY_LOCAL_MACHINE.

F-PROT Antivirus and Command Anti-Malware are products of CYREN