Deployment in Visual Studio 
SerialNumberTemplate Property 

Specifies a template used to validate serial number entry on a Customer Information dialog box during installation on a target computer.

The SerialNumberTemplate property determines how the text boxes will appear in the dialog box and also whether the serial number is validated only for format, or validated according to a Windows Installer algorithm.

For example, setting the SerialNumberTemplate property to "<### - %%%%>" creates two text boxes separated by a dash surrounded by spaces. Validation for the first box (###) simply verifies that the user has entered three digits. The second box (%%%%) is validated by an algorithm that adds the digits together and divides the sum by 7. If the remainder is 0, validation succeeds; otherwise, it fails.

Editable characters appear in the Customer Information dialog box as placeholders within text boxes; any other characters appear as labels between the text boxes.

NoteNote

A separate text box will be created each time the editable character is changed, for example, entering "#?%" creates three text boxes, each accepting one character.

Settings

Valid editable characters for the SerialNumberTemplate property are:

Character Meaning

#

Requires a digit that will not be included in the validation algorithm.

%

Requires a digit that will be included in the validation algorithm.

?

Requires an alphanumeric character that will not be included in the validation algorithm.

^

Requires an uppercase or lowercase character. Numeric digits are not valid here.

<

Any characters to the left of this character will not be visible in the dialog box.

>

Any characters to the right of this character will not be visible in the dialog box. Required as a terminator if the < character is used.

Any other character is treated as a literal constant.

Remarks

If the ShowSerialNumber property is set to true, the serial number will be validated against the template specified in the SerialNumberTemplate property before the user is allowed to move to the next installation step. If the ShowSerialNumber property is set to false, the SerialNumberTemplate property has no effect.

See Also

Reference

Properties for the User Interface Editor
ShowSerialNumber Property

Tags :


Community Content

shoagMSFT
How to create a serial number template

This is a somewhat tricky property; some further explanation is in order. Let's take a look at an actual Microsoft product key as an example:

 

The key "CB48T - GGBCX - H269K - C9W64 - X2RWD" would be represented in the SerialNumberTemplate property as "^^%#^ - ^^^^^ - ^%%%^ - ^%^%% - ^%^^^" - the "^" characters represent placeholders for letters, the "#" character represents a number that is ignored, and the "%" character represents a number that will be evaluated by the validation algorithm. So in this case, if you add together the numbers represented by "%" and ignore the number represented by "#" you get 42; dividing this by 7 leaves a remainder of 0 so the validation succeeds.

 

If you were to use this same template for your product key, you would need to generate a series of keys to provide to your customers when you distribute your program, randomizing the placeholder characters, and also randomizing the numbers but making sure that the numbers represented by "%" are divisible by 7.

 

Note that there is a seemingly arbitrary restriction in that each time you change the editable character a new text box is created, so the above example would create 12 textboxes, not 5 as in a Microsoft product key. To get around this restriction, make sure that only one grouping contains the numbers that you will validate, and use the "?" character in all of the other fields: "????? - %%%%% - ????? - ????? - ?????". You could still use a mix of numbers and letters in your keys, but the second box would always contain numbers - i.e. "BC45T - 340707 - 1XFFE - EFT22 - 1XYZ3".

Tags :

Top Bloke
Better encryption
It appears that entering 7 or 0 for all characters in "????? - %%%%% - ????? - ????? - ?????"  will validate, not what we want. On the other hand This "<??^? - %### - ^?^ - #%%% - ^??^>" will not, which is what we want. We cant mix ? or ^ with % or # or a new box is created, (%##^) would make 2 boxes and (%#^#) would make 3 boxes, therefore the reason for mixing ? and ^ is that they combine to form a box which will except numbers or letters but the letters must be in the right place when entered by the user making it much harder to find the combination.
Tags :

Oleksandr Kovalov
It's very easy to break this "encription"

It's very-very easy to break this "encryption".
No matter what key is.
Just start to enter a character (let's say "G"). If you receive the message "Unacceptable character. You can type only digits here" - type all the "7" in this text box.
In the next text box start typing "G" again.
That's it! The key will be accepted!

Tags :

Page view tracker