Powershell将多个密钥导出到一个.reg文件 [英] Powershell Export Multiple Keys To One .reg File
本文介绍了Powershell将多个密钥导出到一个.reg文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想将多个注册表项导出到同一个.reg文件.我所看到的每个建议都显示使用reg/e [key name] filename.reg,但是我要导出的列表包含4-5个注册表项,并且每次这样做都会覆盖它. 我想要的是这样的:
I would like to export multiple registry keys to the same .reg file. Every suggestion I've seen shows to use reg /e [key name] filename.reg, but I have a list of 4-5 registry entries I want to export and doing it this way will overwrite it each time. What I want is something like:
- 导出HKLM \ Software \ Test \ ABC RegFile.reg
- 导出HKLM \ Software \ ABC \ 123 RegFile.reg
- 导出HKLM \ Software \ XYZ \ Lala RegFile.reg
使每个注册表项都附加到相同的.reg文件中,而不是每次都覆盖.我该怎么办?
So that each registry key is appended to the same .reg file, not overwritten each time. How can I do this?
推荐答案
最简单的方法是分别导出每个密钥,然后合并生成的文件:
The simplest way would be to export each key individually, and then merge the resulting files:
$keys = 'HKLM\Software\Test\ABC', 'HKLM\Software\ABC\123', ...
$tempFolder = 'C:\temp\folder'
$outputFile = 'C:\path\to\merged.reg'
$keys | % {
$i++
& reg export $_ "$tempFolder\$i.reg"
}
'Windows Registry Editor Version 5.00' | Set-Content $outputFile
Get-Content "$tempFolder\*.reg" | ? {
$_ -ne 'Windows Registry Editor Version 5.00'
} | Add-Content $outputFile
这篇关于Powershell将多个密钥导出到一个.reg文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文