我尝试使用PowerShell设置本地组策略。 我的目标是启用
禁用更改主页设置
以下是PowerShell脚本:
# Set the values as needed $dchps_control_panel = "HKCU:\Software\Policies\Microsoft\Internet Explorer\Control Panel" $dchps_main = "HKCU:\Software\Policies\Microsoft\Internet Explorer\Main" $homepage = "HomePage" $enabled = 1 $startpage = "Start Page" $startpage_value = "www.google.com" # Test if the Registry Key exists already if(-not (Test-Path $dchps_control_panel) -or -not (Test-Path $dchps_main) ) { # Create Control Panel Key to enable and Main Key New-Item -Path $dchps_control_panel -Force New-Item -Path $dchps_main -Force } # Enable Disable changing home page settings Set-ItemProperty -Path $dchps_control_panel -Name $homepage -Value $enabled -Type DWord # # Set Start Page Set-ItemProperty -Path $dchps_main -Name $startpage -Value $startpage_value -Type String
registry项都被创build。 但是,当我检查“gpedit.msc”的设置仍然是禁用和没有configuration。
谢谢
正如所料,您需要额外的工具。 如果您在更改过程中运行procmon,它会向您显示实际的registry项,该项位于GUID下,我还没有find以编程方式解决的方法。
HKCU\Software\Microsoft\Windows\CurrentVersion\Group Policy Objects\{<GUID>}User\Software\Policies\Microsoft\Internet Explorer\Main\Start Page
此外,如果您检查registry.pol,您将看到条目,但是您将无法直接编辑它。
gc C:\Windows\System32\GroupPolicy\User\Registry.pol -Encoding Unicode