我正在尝试阅读离线注册表文件:
$product_name = Get-ItemProperty -Path "C:\temp\RegistryHives\SOFTWARE\Microsoft\Windows NT\CurrentVersion" -name ProductName | Select-Object -ExpandProperty ProductName
获取以下错误。访问脱机注册表文件键和值的正确方法是什么?
Get-ItemProperty : Cannot find path 'C:\temp\RegistryHives\SOFTWARE\Microsoft\Windows NT\CurrentVersion' because it
does not exist.
At line:1 char:17
+ ... duct_name = Get-ItemProperty -Path "C:\temp\RegistryHives\SOFTWARE\Mi ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (C:\temp\Registr...\CurrentVersion:String) [Get-ItemProperty], ItemNotFo
undException
+ FullyQualifiedErrorId : PathNotFound,Microsoft.PowerShell.Commands.GetItemPropertyCommand
答案 0 :(得分:2)
您需要在访问之前加载注册表。 reg.exe
可以使用load
命令
Reg.exe load 'HKLM\TempHive' C:\temp\RegistryHives\SOFTWARE
$product_name = Get-ItemProperty -Path "HKLM:\TempHive\Microsoft\Windows NT\CurrentVersion" -name ProductName | Select-Object -ExpandProperty ProductName
Reg.exe unload 'HKLM\TempHive'