许多人在访问某些网站或在出门在外的Internet上工作时要保护自己的身份的一件常见事情是使用代理服务器。匿名代理服务器将隐藏您的真实IP,如果您因某些原因被禁止进入某些论坛或网站,但人们出于商业原因也使用代理服务器,这将非常有用。
何时您在办公室时,可能要使用公司的内部代理服务器访问Internet,但是当您漫游或在家时,您只希望计算机自动检测代理设置。
Where A Proxy Server Is Configured
Before we get into the ways that you can automate your computer through scripting, let’s take a quick look at the manual way people would have to do this. Most people know how to configure their LAN settings – it’s one of the first things you should check if you’re ever having Internet connection problems. Typically you want your proxy settings to be set to “Automatically detect settings” when you’re at home or at a public hotspot.
但是,在工作中,您需要设置代理服务器。您可以通过在控制面板的“ Internet属性"中单击“ LAN设置"按钮来执行此操作。
在网络设置对话框中,您可以将会看到这两个设置–您启用了代理服务器,还是没有启用。当您从家庭网络切换到工作网络,或者要切换到在“隐蔽的"匿名IP服务器下运行时,这是您要切换的设置。
您还可以找到这些设置注册表中的设置(单击 Run 并键入“ regedit "),这就是您要编辑脚本的内容。通过更改注册表设置,您实际上是在“ LAN设置"窗口中更改了这些设置。
我们真正想要做的是仅在您真正想要的时间和位置切换这些设置。我将介绍三种情况,您可以复制并粘贴代码以根据自己的喜好进行调整。您可以将脚本放入启动文件夹中,以便在启动计算机时启动脚本,也可以在希望计算机自动设置正确的IP设置时运行脚本。
这三种情况'将提供包括以下内容的脚本。
Windows Scripting Host的优点是每个选项都不难。
询问用户以启用代理服务器
此脚本将弹出一个消息框,询问用户是否要使用代理服务器。如果是,则脚本将启用代理服务器并填写硬编码的匿名代理服务器。您可以调整脚本以使用您喜欢的匿名代理。
这是脚本的样子。
<job><script language="VBScript">Option ExplicitDim valUserInDim objShell, RegLocate, RegLocate1Set objShell = WScript.CreateObject("WScript.Shell")On Error Resume NextvalUserIn = MsgBox("Use A Cloaked Proxy?",4,"Cloaked Select")If valUserIn=vbYes ThenRegLocate = "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings\ProxyServer"objShell.RegWrite RegLocate,"http://www.youareanonymous.com:80","REG_SZ"RegLocate = "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings\ProxyEnable"objShell.RegWrite RegLocate,"1","REG_DWORD"MsgBox "Cloaked Proxy is Enabled"elseRegLocate = "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings\ProxyServer"objShell.RegWrite RegLocate,"0.0.0.0:80","REG_SZ"RegLocate = "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings\ProxyEnable"objShell.RegWrite RegLocate,"0","REG_DWORD"MsgBox "Cloaked Proxy is Disabled"End IfWScript.Quit</script></job></textarea>
运行该脚本时,用户会看到以下提示。
“是"将匿名代理加载为您的代理服务器并将“ ProxyEnable"设置为1。“否"将代理设置为默认全零,并禁用代理设置。
提示用户输入代理
另一个方法是询问用户他们要使用什么确切的服务器。这样就可以灵活地不断更改代理服务器,而无需编辑脚本本身。您可以通过将“ MsgBox"命令更改为“ InputBox"来完成此操作。
<job><script language="VBScript">Option ExplicitDim valUserInDim objShell, RegLocate, RegLocate1Set objShell = WScript.CreateObject("WScript.Shell")On Error Resume NextvalUserIn = Inputbox("Enter the Proxy server you want to use.","Proxy Server Required")RegLocate = "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings\ProxyServer"objShell.RegWrite RegLocate,valUserIn,"REG_SZ"RegLocate = "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings\ProxyEnable"objShell.RegWrite RegLocate,"1","REG_DWORD"MsgBox "Proxy is Enabled"WScript.Quit</script></job>
将其另存为.wsf文件并运行时,将出现以下窗口。
只需键入您首选的代理服务器,单击“确定",您的Internet设置就会自动更新。
根据位置设置代理设置
This next script is a little bit more flexible, so it’s also a little longer. But what it can do is check your current IP address, and if it is within the range that you expect when you’re on your home ISP, it’ll disable using a proxy server. If it sees that you’re not on your typically home IP domain, it’ll automatically configure your Internet with a proxy server that you can hard code into the script.
这是脚本的外观。
<job><script language="VBScript">Option ExplicitDim valUserInDim objShell, RegLocate, RegLocate1Dim objRemXMLDim objMyIPDim strIPAddressDim strHostnameDim strHomeDomainOn Error Resume NextSet objShell = WScript.CreateObject("WScript.Shell")On Error Resume NextConst cstrShowMyIP = "http://www.showmyip.com/xml/"Set objRemXML = CreateObject("Microsoft.XMLDOM")objRemXML.async = FalseobjRemXML.load(cstrShowMyIP)' Get our IP addressSet objMyIP = objRemXML.selectSingleNode("/ip_address/ip")strIPAddress = objMyIP.text' Print infoWScript.Echo "IP address : " & strIPAddressstrHomeDomain = Left (strIPAddress,6)If strHomeDomain = "69.161" thenRegLocate = "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings\ProxyServer"objShell.RegWrite RegLocate,"0.0.0.0:80","REG_SZ"RegLocate = "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings\ProxyEnable"objShell.RegWrite RegLocate,"0","REG_DWORD"MsgBox "Cloaked Proxy is Disabled"elseRegLocate = "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings\ProxyServer"objShell.RegWrite RegLocate,"http://www.youareanonymous.com:80","REG_SZ"RegLocate = "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings\ProxyEnable"objShell.RegWrite RegLocate,"1","REG_DWORD"MsgBox "Cloaked Proxy is Enabled"end if' FinishSet objMyIP = NothingSet objRemXML = NothingWScript.Quit </script></job>
You set set this up to run on startup, and the computer will automatically configure the Internet settings as needed. The program will show you your current IP each time – if you don’t want that, just remove the “WPScript.Echo” line. When I run it here at home, it recognizes I’m on my safe home ISP and disables the anonymous proxy.
如果您在公共热点上,它将识别外部IP地址并启用隐藏的代理。
这些只是可以使用Windows Scripting Host内置到Windows PC中的自动化类型的一些示例。您不必是专业的程序员,只需学习这些脚本中的一些命令,您就可以真正发挥作用。
您是否尝试过这些脚本中的任何一个?让我知道您的想法,请提供任何可能使其变得更好的调整或改进。在下面的评论部分中提供您的见解。
图片来源:Mr. Gr4phic3r
标签: