This script sample shows how to get and backup Windows product key in Windows 8 or higher version.
Sometimes a user may want to reinstall operating system, but he does not know the current Windows product key. This script can solve that.
Step 1: Double-click the script, it will show message as following.

Step 2: Press Yes to save Windows product key to a file.

Here are some code snippets for your references.
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
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
Windows 8 or later version