Q: How can I configure my virtual machine (VM) template to set the product key automatically?

A: If you're using VM templates, the easiest way to specify the product key is by using something like System Center 2012 Virtual Machine Manager, which can inject whatever product key you need as part of the template. However, if you want to configure the product key outside of a management solution, you can use an answer file.

Below is a very basic answer file that specifies the Key Management Service (KMS) key for Windows Server 2012 Datacenter:


I save this as unattend.xml in a folder on the machine that will be SYSPREP'd as c:\unattend\unattend.xml.

I then run sysprep, passing this file. For example:

c:\windows\system32\sysprep\sysprep /generalize /shutdown /oobe /unattend:c:\unattend\unattend.xml

When the template is used, there will be no prompt for the product key. In the past, keys were set as part of the specialist phase, for example: