|
|
- # 设置注册表路径(官方推荐路径)
- $regPath = "HKCU:\Software\Policies\Microsoft\Edge"
- $homePageKey = "HomepageLocation"
- $openOnStartKey = "OpenHomepageOnStart"
- $homePageValue = "https://www.example.com"
- # 检查注册表路径是否存在,如果不存在则创建
- if (-not (Test-Path $regPath)) {
- try {
- New-Item -Path $regPath -Force | Out-Null
- Write-Host "注册表路径已创建:$regPath"
- }
- catch {
- Write-Error "无法创建注册表路径:$regPath。请以管理员身份运行 PowerShell。"
- exit
- }
- }
- # 设置主页地址
- try {
- Set-ItemProperty -Path $regPath -Name $homePageKey -Value $homePageValue -Force
- Write-Host "主页已设置为:$homePageValue"
- }
- catch {
- Write-Error "无法设置主页键值:$homePageKey"
- }
- # 启用启动时打开主页
- try {
- Set-ItemProperty -Path $regPath -Name $openOnStartKey -Value 1 -Force
- Write-Host "已启用:启动时打开主页"
- }
- catch {
- Write-Error "无法设置启动时打开主页键值:$openOnStartKey"
- }
复制代码
|
|