Windows7/10/11 Pac代理脚本及配置

Windows7/10/11 Pac代理脚本及配置

代理自动配置(PAC)文件是一个 JavaScript 脚本,其核心是一个 JavaScript 函数,用来决定网页浏览请求(HTTP、HTTPS,和 FTP)应当直连目标地址,还是被转发给一个网页代理服务器并通过代理连接。

一、Pac脚本编写

以下配置保存到文件,扩展名为pac

function FindProxyForURL(url, host) {
	var proxy1 = "PROXY 192.168.6.6:6666";
	var proxy2 = "PROXY 222.22.66.222:6666";
	
    //本地地址直接连接
	if (isPlainHostName(host)) {
        return "DIRECT";
    }
	// 代理1
	if (shExpMatch(url, "*baidu.com*")) {
        return proxy1;
    }
	// 代理2
	if (shExpMatch(url, "*csdn.com*")) {
	   return proxy2;
	}
    return "DIRECT";
}

二、Windows配置

1.界面配置

在这里插入图片描述

2.命令配置

以下配置保存到文件执行,扩展名为bat,windows的dos命令

@echo off
color 0a
title Use autoconfig script
echo Starting......
reg add "HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings" /v ProxyEnable /t REG_DWORD /d 0 /f
reg add "HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings\Connections" /v DefaultConnectionSettings /t REG_BINARY /d 46000000020000000900 /f
reg add "HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings\Connections" /v SavedLegacySettings /t REG_BINARY /d 46000000020000000900 /f
reg add "HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings" /v AutoConfigURL /d "http://域名/pac/proxy.pac" /f
echo End
@echo off

三、注意事项

  • pac脚本中尽量不要写注释(在某些操作系统版本,导致脚本不能正确加载)

  • 不支持 ftp:// 或 file:// 协议(Win10)

  • https不生效(IE、Chrome)

不支持 ftp:// 或 file:// 协议(Win10)

出现此问题的原因是基于 Windows 10 的计算机上的 Internet Explorer 和 Microsoft Edge 使用 WinHttp 代理服务来检索代理服务器信息。 WinHttp 代理服务不支持对 PAC 文件使用 ftp:// 或 file:// 协议。
原文地址:
https://learn.microsoft.com/zh-cn/troubleshoot/developer/browsers/administration/cannot-read-pac-file

https不生效(IE、Chrome)

1.IE浏览器

可以修改注册表配置后支持(需要重启系统)

配置内容

以下配置保存到文件执行,扩展名为reg,注册表命令

Windows Registry Editor Version 5.00

[HKEY_CURRENT_USER\Software\Policies\Microsoft\Windows\CurrentVersion\Internet Settings]
"EnableAutoproxyResultCache"=0

原文地址:
https://support.microsoft.com/en-us/topic/how-to-disable-automatic-proxy-caching-in-internet-explorer-92735c9c-8a26-d0d8-7f8a-1b46595cbaba

部分原文:

HKEY_CURRENT_USER\Software\Policies\Microsoft\Windows\CurrentVersion\Internet Settings

Value: EnableAutoproxyResultCache
Type: REG_DWORD
Data value: 0 = disable caching; 1 (or key not present) = enable automatic proxy caching (this is the default behavior)If the registry key is not present, you can create the registry key by using the following registry file:

Windows Registry Editor Version 5.00

[HKEY_CURRENT_USER\Software\Policies\Microsoft\Windows\CurrentVersion\Internet Settings]"EnableAutoProxyResultCache"=dword:00000000"
2.Google浏览器

不支持
原文地址:
https://developer.mozilla.org/zh-CN/docs/Web/HTTP/Proxy_servers_and_tunneling/Proxy_Auto-Configuration_PAC_file

在这里插入图片描述

参考资料
1.代理自动配置文件(PAC)文件
2.Windows 10不读取文件协议引用的 PAC 文件

抱歉,由于我的回答文本长度限制,无法完整显示您提供的URL。但是我明白您遇到了在计算机上找不到任何SQL Server cmdlet的问题。您可以尝试以下几个步骤来解决这个问题: 1. 确认已安装SQL Server PowerShell模块:首先,请确保您已经在计算机上安装了SQL Server PowerShell模块。您可以通过在PowerShell命令提示符中运行以下命令来检查是否已安装:`Get-Module -ListAvailable -Name SqlServer`。如果没有任何输出,表示模块未安装。 2. 安装SQL Server PowerShell模块:如果您尚未安装SQL Server PowerShell模块,可以通过以下步骤进行安装: - 打开PowerShell命令提示符。 - 运行以下命令来安装模块:`Install-Module -Name SqlServer`。如果提示更新模块,请按照提示进行操作。 - 完成安装后,您可以使用`Import-Module SqlServer`命令导入模块。 3. 检查PowerShell版本:确保您的计算机上安装了兼容的PowerShell版本。一些SQL Server PowerShell模块可能需要较新的PowerShell版本才能正常工作。您可以通过运行`$PSVersionTable.PSVersion`命令来检查PowerShell版本。 4. 更新SQL Server PowerShell模块:如果您已经安装了SQL Server PowerShell模块,但仍然遇到问题,请考虑更新模块到最新版本。您可以使用`Update-Module -Name SqlServer`命令来更新模块。 如果您仍然无法解决问题,请提供更多详细信息,例如错误消息或任何其他相关的信息,以便我能更好地帮助您。
评论 6
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值