我与您共享一个Python脚本,该脚本可让您轻松修改Windows代理系统。 我认为有很多人在使用此代理系统的公司工作,每次要使用专用网络(而不是公司网络)时手动更改它都是很烦人的。
import winreg
# Open register key to Internet Settings
INTERNET_SETTINGS = winreg.OpenKey(winreg.HKEY_CURRENT_USER,
r'Software\Microsoft\Windows\CurrentVersion\Internet Settings',
0, winreg.KEY_ALL_ACCESS)
# Get reg_type of needed key and set new value to it
def set_key(name, value):
_, reg_type = winreg.QueryValueEx(INTERNET_SETTINGS, name)
winreg.SetValueEx(INTERNET_SETTINGS, name, 0, reg_type, value)
# Configure a proxy system address
proxy_system = u'XXX.XXX.com:8080'
choice = input("Would you like to enable proxy system (Y/N): ")
try :
if(choice == 'Y' or choice == 'y'):
set_key('ProxyEnable', 1)
print("Your proxy system is enabled")
else:
set_key('ProxyEnable', 0)
print("Your proxy system is disabled")
# If you want to change Proxy adress
#set_key('ProxyServer', proxy_system)
except :
print("Error your proxy system was not updated")
您可以配置Windows在系统启动时执行此脚本。