繁体   English   中英

使用 PowerShell 将 .reg 文件与 Windows 注册表合并

[英]Use PowerShell to merge .reg file with Windows registry

运行以下任何命令都不会产生在 Windows Explorer 中显示导航窗格的预期结果。

GUI 工作方式:右键单击 .reg 文件和 select 合并。 如果 UAC 提示,请单击“是”。 单击是以确认您要添加注册表项。

shownavigationpane.reg 的内容:Windows 注册表编辑器版本 5.00

[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Modules\GlobalSettings\Sizer] "PageSpaceControlSizer"=hex:a0,00,00,00,01,00,00,00,00,00,00,00,56,05,00,00

我已经尝试了以下 5 个 PowerShell 命令,它们分别以 Set-ExecutionPolicy unrestricted 开头,但没有一个产生预期的结果。 我已经在 Windows 资源管理器关闭的情况下运行了命令。

  1. reg import c:\ps\shownavigationpane.reg

  2. start-process reg -ArgumentList "import C:\temp\shownavigationpane.reg"

  3. regedit /s "C:\temp\shownavigationpane.reg"

  4. Invoke-Command -ScriptBlock {reg import c:\temp\shownavigationpane.reg}

  5. Start-Process -filepath "C:\windows\regedit.exe" -argumentlist "/s c:\temp\shownavigationpane.reg"

我同意jrider 的评论,但想提供一个替代解决方案

如果那是您想要在注册表中更改的唯一设置,您可以直接从 PowerShell 中执行此操作:

$regPath = 'Registry::HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Modules\GlobalSettings\Sizer'
# if that registry path does not already exist, create it here
$null = New-Item -Path $regPath -Force

$values = [byte[]](0xa0, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x56, 0x05, 0x00, 0x00)
Set-ItemProperty -Path $regPath -Name 'PageSpaceControlSizer' -Value $values -Type Binary -Force

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM