gpt4 book ai didi

internet-explorer - 如何使用 powershell 应用更改的代理设置 (AutoConfigURL)

转载 作者:行者123 更新时间:2023-12-04 07:44:09 25 4
gpt4 key购买 nike

我的代理是使用 IE 的 LAN 设置对话框中的“自动配置脚本”选项配置的。为了切换此设置,我编写了以下 powershell 脚本:

$proxyScript = 'http://example.com/files/wish.pac'
$debug = $TRUE
$currentValue = Get-ItemProperty -Path HKCU:"Software\Microsoft\Windows\CurrentVersion\Internet Settings" -Name AutoConfigURL -ErrorAction SilentlyContinue

if($debug)
{
Get-ItemProperty -Path HKCU:"Software\Microsoft\Windows\CurrentVersion\Internet Settings"
}

if([string]::IsNullOrEmpty($currentValue))
{
Write-Host "Proxy-AutoConfigURL is actually disabled"
Set-ItemProperty -Path HKCU:"Software\Microsoft\Windows\CurrentVersion\Internet Settings" -Name AutoConfigURL -value $proxyScript
Write-Host "Proxy-AutoConfigURL is enabled: " + $proxyScript
}
else
{
Write-Host "Proxy-AutoConfigURL is actually enabled"
Remove-ItemProperty -Path HKCU:"Software\Microsoft\Windows\CurrentVersion\Internet Settings" -Name AutoConfigURL
Write-Host "Proxy-AutoConfigURL is disabled."
}

if($debug)
{
Get-ItemProperty -Path HKCU:"Software\Microsoft\Windows\CurrentVersion\Internet Settings"
}

该脚本似乎可以工作,因为在执行脚本后 IE 的 LAN 设置对话框中的值发生了变化。但它们似乎不适用于 IE 和其他使用系统范围设置的应用程序。只有当我单击 LAN 设置对话框中的 OK 按钮时,才会应用更新的值。

有没有办法使用 powershell 自动应用更改的设置?

最佳答案

您需要通知系统有关更新。查看我的代理模块,它不处理自动配置,但原理是一样的

https://github.com/majkinetor/posh/blob/master/MM_Network/Update-Proxy.ps1

refresh-system功能。

关于internet-explorer - 如何使用 powershell 应用更改的代理设置 (AutoConfigURL),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29623788/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com