在 Windows 10、8 和 8.1 上備份產品金鑰的 2 種方法

在 Windows 10、8 和 8.1 上備份產品金鑰的 2 種方法

當您的Windows作業系統出現嚴重錯誤或崩潰等情況時,修復錯誤的解決方案通常是重新安裝作業系統。 Windows 使用者將必須使用產品金鑰來重新安裝作業系統。但是,要「購買」產品金鑰,您將需要支付一筆可觀的費用。

如果您不想支付任何費用,最好備份您的產品金鑰或啟動金鑰,以防出現問題。在下面的文章中,LuckyTemplates 將引導您完成在 Windows 10、8 和 Windows 8.1 上備份產品金鑰的 2 種方法。

另外,讀者可以在這裡參考文章《在 Windows 10 上更改產品金鑰的 5 種方法》

1. 在 Windows 10、8 和 Windows 8.1 上備份產品金鑰

請依照下列步驟在 Windows 10、8 和 Windows 8.1 上備份產品金鑰:

步驟1:

按Windows + R組合鍵開啟「執行」命令窗口,然後在「執行」命令視窗中輸入「notepad」並按Enter或按一下「確定」開啟新的記事本。

在 Windows 10、8 和 8.1 上備份產品金鑰的 2 種方法

第2步:

在新的記事本上,複製並貼上以下腳本:

#Main function
Function GetWin8Key
{
$Hklm = 2147483650
$Target = $env:COMPUTERNAME
$regPath = "Software\Microsoft\Windows NT\CurrentVersion"
$DigitalID = "DigitalProductId"
$wmi = [WMIClass]"\\$Target\root\default:stdRegProv"
#Get registry value
$Object = $wmi.GetBinaryValue($hklm,$regPath,$DigitalID)
[Array]$DigitalIDvalue = $Object.uValue
#If get successed
If($DigitalIDvalue)
{
#Get producnt name and product ID
$ProductName = (Get-itemproperty -Path "HKLM:Software\Microsoft\Windows NT\CurrentVersion" -Name "ProductName").ProductName
$ProductID = (Get-itemproperty -Path "HKLM:Software\Microsoft\Windows NT\CurrentVersion" -Name "ProductId").ProductId
#Convert binary value to serial number
$Result = ConvertTokey $DigitalIDvalue
$OSInfo = (Get-WmiObject "Win32_OperatingSystem" | select Caption).Caption
If($OSInfo -match "Microsoft Windows 8" -or $OSInfo -match "Microsoft Windows 10")
{
if($Result)
{ [string]$value ="ProductName : $ProductName `r`n" `
+ "ProductID : $ProductID `r`n" `
+ "Installed Key: $Result"
$value
#Save Windows info to a file
$Choice = GetChoice
If( $Choice -eq 0 )
{
$txtpath = "C:\Users\"+$env:USERNAME+"\Desktop"
New-Item -Path $txtpath -Name "WindowsKeybackup.txt" -Value $value -ItemType File -Force | Out-Null
}
Elseif($Choice -eq 1)
{
Exit
}
}
Else
{
Write-Warning "Please run this script on Windows 8.x or Windows 10"
}
}
Else
{
Write-Warning "Please run this script on Windows 8."
} }
Else
{
Write-Warning "Failed to get Windows 8 product key,Some error occured."
}}
#Get user choice
Function GetChoice
{
$yes = New-Object System.Management.Automation.Host.ChoiceDescription "&Yes",""
$no = New-Object System.Management.Automation.Host.ChoiceDescription "&No",""
$choices = [System.Management.Automation.Host.ChoiceDescription[]]($yes,$no)
$caption = "Confirming"
$message = "Save product key to a file?"
$result = $Host.UI.PromptForChoice($caption,$message,$choices,0)
$result
}
#Convert binary to serial number
Function ConvertToKey($Key)
{
$Keyoffset = 52
$isWin8 = [int]($Key[66]/6) -band 1
$HF7 = 0xF7
$Key[66] = ($Key[66] -band $HF7) -bOr (($isWin8 -band 2) * 4)
$i = 24
[String]$Chars = "BCDFGHJKMPQRTVWXY2346789"
do
{
$Cur = 0
$X = 14
Do
{
$Cur = $Cur * 256
$Cur = $Key[$X + $Keyoffset] + $Cur
$Key[$X + $Keyoffset] = [math]::Floor([double]($Cur/24))
$Cur = $Cur % 24
$X = $X - 1
}while($X -ge 0)
$i = $i- 1
$KeyOutput = $Chars.SubString($Cur,1) + $KeyOutput
$last = $Cur
}while($i -ge 0) $Keypart1 = $KeyOutput.SubString(1,$last)
$Keypart2 = $KeyOutput.Substring(1,$KeyOutput.length-1)
if($last -eq 0 )
{
$KeyOutput = "N" + $Keypart2
}
else
{
$KeyOutput = $Keypart2.Insert($Keypart2.IndexOf($Keypart1)+$Keypart1.length,"N")
}
$a = $KeyOutput.Substring(0,5)
$b = $KeyOutput.substring(5,5)
$c = $KeyOutput.substring(10,5)
$d = $KeyOutput.substring(15,5)
$e = $KeyOutput.substring(20,5)
$keyproduct = $a + "-" + $b + "-"+ $c + "-"+ $d + "-"+ $e
$keyproduct }

GetWin8Key

步驟3:

選擇儲存位置並為檔案指定任意名稱,並記住新增副檔名.ps1(刪除 .txt 副檔名)。

例如:

如果您想要將檔案命名為Windowsbackupproductkey ,請在檔案名稱」方塊中輸入全名Windowsbackupproductkey.ps1 。

在 Windows 10、8 和 8.1 上備份產品金鑰的 2 種方法

點擊“儲存”以儲存檔案。

步驟4:

右鍵單擊剛剛建立的文件,然後選擇“使用 PowerShell 運行”

在 Windows 10、8 和 8.1 上備份產品金鑰的 2 種方法

第5步:

PowerShell 會要求您確認是否要在電腦上儲存產品金鑰的副本。輸入Y,然後按 Enter 確認。

在 Windows 10、8 和 8.1 上備份產品金鑰的 2 種方法

第6步:

您在 Windows 10、8.1 和 8 上備份的產品金鑰將保存在電腦上的WindowsKeybackup.txt檔案中。

在 Windows 10、8 和 8.1 上備份產品金鑰的 2 種方法

2. 在 Windows 10、8.1 和 8 上備份產品金鑰的 PowerShell 腳本

除了上述方法外,您還可以在 Windows 10、8.1 和 8 上下載 PowerShell 腳本來備份產品金鑰。

在此處將 PowerShell 腳本下載到您的電腦

  1. 解壓縮您剛剛下載的 WindowsKeybackup.rar 檔案。
  2. 右鍵點選名為windowsbackupproductkey.ps1的文件,然後選擇使用 PowerShell 執行
  3. 在 PowerShell 視窗中輸入Y ,然後按 Enter。

現在您可以看到您在 Windows 10、8.1 和 8 電腦上備份的產品金鑰。

此外,您可以手動記錄您的Windows 10密鑰,然後當您完成電腦的安裝和修復後,只需再次輸入Windows密鑰即可。

更多的文章可以參考下面的文章:

祝你好運!


如何在 Windows 中驗證 MD5、SHA-1 和 SHA-256 校驗和

如何在 Windows 中驗證 MD5、SHA-1 和 SHA-256 校驗和

透過檢查檔案的 MD5、SHA-1 或 SHA-256 校驗和,您可以驗證檔案的完整性並確保檔案沒有損壞或變更。

什麼是 FileRepMalware?刪除有沒有問題?

什麼是 FileRepMalware?刪除有沒有問題?

防毒軟體有一定的標準來過濾掉系統中的可疑檔案、應用程式和進程。 FileRepMalware 就是其中之一。那麼這是什麼?他們安全嗎?刪除還是不刪除這些檔案?

什麼是橢圓曲線密碼學 (ECC)?

什麼是橢圓曲線密碼學 (ECC)?

什麼是橢圓曲線密碼學?為什麼當今科技領域有這麼多關於此類密碼學的資訊?

如何在 Windows 上啟用勒索軟體防護功能

如何在 Windows 上啟用勒索軟體防護功能

勒索軟體保護是 Windows 11 附帶的實用功能,可協助保護使用者的裝置免受勒索軟體攻擊。

如何在Windows 10上快速定位滑鼠遊標

如何在Windows 10上快速定位滑鼠遊標

如果你經常需要使用大螢幕,那麼丟失微小的滑鼠指標肯定不是罕見的情況。

如何在 Windows 中使用 Net Use 命令

如何在 Windows 中使用 Net Use 命令

net use 指令是一個指令提示字元指令,用於連線、刪除和設定與共用資源(例如對應磁碟機和網路印表機)的連線。

了解端點安全

了解端點安全

現代資訊科技的世界帶來了許多好處,但也為壞人提供了有利條件。

10 個增強遊戲效能的最佳 GPU 超頻工具

10 個增強遊戲效能的最佳 GPU 超頻工具

GPU超頻是使用第三方軟體提高顯示卡效能的過程。您可以增強 GPU 以提供更好的效能。

如何恢復 Windows 10 中遺失的預設電源計劃

如何恢復 Windows 10 中遺失的預設電源計劃

本指南將向您展示如何恢復 Windows 10 中缺少的預設電源計劃「平衡」、「高效能」、「省電」或「終極效能」。

如果電腦當機,請按此組合鍵

如果電腦當機,請按此組合鍵

有一個鮮為人知的組合鍵可以幫助您將設備恢復到正常狀態。