Scenario. You have a Windows 7 key and want to farm a Windows 10 key from it, using the automatic upgrade. Of course, you want to do this in a <a href="https://www.virtualbox.org" target="_blank">VirtualBox</a> ((Side note. If you have a <a href="/2012/03/23/windows-customization/">customized Windows</a>, you possibly need to install <a href="https://www.virtualbox.org/wiki/Download_Old_Builds_4_3_pre24">Virtual Box 4.3.12</a> because anything after that will throw <a href="https://www.virtualbox.org/ticket/13504?cversion=1&cnum_hist=1" target="_blank">an error</a>.)). The first thing you do is, set up a VM with at least 30GB of harddrive. Let's assume that this VM is called <b>Nekarat</b>. This is an outdated pop culture reference, <a href="https://www.google.com/search?q=Nekarat" target="_blank">google it</a>.
In the host system (not the VM), go to your happy place (i.e. <b>cmd.exe</b>) and do this:
```bash
cd c:\Program Files\Oracle\VirtualBox
VBoxManage.exe setextradata Nekarat VBoxInternal/CPUM/CMPXCHG16B 1
```
It will not seem like anything has happened, but trust me, it did. It enables a certain CPU instruction for the virtual machine without whome <a href="http://www.dirkstrauss.com/how-to/virtualbox-compareexchange128-error" target="_blank">the Windows 10 update fails</a>.</li>
Boot the VM. Install Windows and update it completely. Do <b>not</b> install the VirtualBox Guest additions: The display driver is incompatible with the Windows 10 update. Now might be a good time to make a snapshot if you want to upgrade more than one key. Activate Windows. Then, in the VM, add this to the registry, <a href="http://www.filecritic.com/how-to-fix-the-something-happened-0x80070002-0x20016-error-and-upgrade-to-windows-10/" target="_blank">courtesy of filecritic.com</a>:
```text
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate\OSUpgrade]
"AllowOSUpgrade"=dword:00000001
```
Check for updates, it should now download Windows 10. <span id="more-3446"></span> After that part is done, create a file called <b>key.vbs</b> and put this inside:
```vb
Option Explicit
Dim objshell,path,DigitalID, Result
Set objshell = CreateObject("WScript.Shell")
Path = "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\"
DigitalID = objshell.RegRead(Path & "DigitalProductId")
Dim ProductName,ProductID,ProductKey,ProductData
ProductName = "Product Name: " & objshell.RegRead(Path & "ProductName")
ProductID = "Product ID: " & objshell.RegRead(Path & "ProductID")
ProductKey = "Product Key: " & ConvertToKey(DigitalID)
ProductData = ProductName & vbNewLine & ProductID & vbNewLine & ProductKey
WScript.echo ProductData
Function ConvertToKey(Key)
Const KeyOffset = 52
Dim isWin8, Maps, i, j, Current, KeyOutput, Last, keypart1, insert
'Check if OS is Windows 8
isWin8 = (Key(66) \ 6) And 1
Key(66) = (Key(66) And &HF7) Or ((isWin8 And 2) * 4)
i = 24
Maps = "BCDFGHJKMPQRTVWXY2346789"
Do
Current= 0
j = 14
Do
Current = Current* 256
Current = Key(j + KeyOffset) + Current
Key(j + KeyOffset) = (Current \ 24)
Current=Current Mod 24
j = j -1
Loop While j >= 0
i = i -1
KeyOutput = Mid(Maps,Current+ 1, 1) & KeyOutput
Last = Current
Loop While i >= 0
keypart1 = Mid(KeyOutput, 2, Last)
insert = "N"
KeyOutput = Replace(KeyOutput, keypart1, keypart1 & insert, 2, 1, 0)
If Last = 0 Then KeyOutput = insert & KeyOutput
ConvertToKey = Mid(KeyOutput, 1, 5) & "-" & Mid(KeyOutput, 6, 5) & _
"-" & Mid(KeyOutput, 11, 5) & "-" & Mid(KeyOutput, 16, 5) & "-" & _
Mid(KeyOutput, 21, 5)
End Function
```
And from your commandline in the VM, run the command <b>cscript key.vbs</b>. There you go, key farmed.
2 Replies to “How to farm the Win10 key from a Win7 Upgrade in VirtualBox”