Change Product Key in Windows Server 2012 via command line

To change the Product Key on Windows Server 2012 and activate it via command line run the following commands below.

To remove all installed keys run the following command:

 slmgr.vbs -upk 

To add the new key, run the command below:

slmgr.vbs -ipk XXXXX-XXXXX-XXXXX-XXXXX-XXXXX

Obviously change XXXXX-XXXXX-XXXXX-XXXXX-XXXXX with your actual key.

And that’s it! The Product Key has been changed and activated successfully. If you have to do this many times it makes sense to script this, so the batch file below achieves all the steps above in one go:

::Remove all installed keys
slmgr.vbs -upk

::Install new product key
slmgr.vbs -ipk XXXXX-XXXXX-XXXXX-XXXXX-XXXXX

I hope this helps you save a bit of time and energy!