深圳创意园在哪:一键修改hosts文件访问Google | 祥子的博客#more

来源:百度文库 编辑:中财网 时间:2024/05/01 00:35:01

一键修改hosts文件访问Google

Google上不去怎么办?可以使用Google的镜像IP地址来访问Google,Google有很多IP地址,通过IP可以直接访问Google。这个脚本通过ping找到访问最快的ip,写入hosts文件。

可以解决大部分Google无法访问或进不去的问题。不用fq,腰不酸,腿不疼了。

之后就可以登录 google ssl了 https://encrypted.google.com/?hl=zh-CN 不解释

具体的方法就是在桌面或者其他随便一个目录创建一个批处理脚本sethosts.bat,脚本内容如下(前提:你的cmd是英文版的):

@echo off

ping www.google.cn -n 1| find "Reply from">ip.txt

for /f "tokens=3 delims= " %%i in (ip.txt) do set googleip=%%i

echo %googleip%

findstr /e /v /r /c:"google.com" "C:\Windows\System32\drivers\etc\hosts">>hosts

echo %googleip:~0,-1% encrypted.google.com>>hosts

echo %googleip:~0,-1% docs.google.com>>hosts

echo %googleip:~0,-1% code.google.com>>hosts

echo %googleip:~0,-1% google.com>>hosts

copy hosts "C:\Windows\System32\drivers\etc\hosts" /y

del hosts /f  /q

保存,执行,OK!

如果你的cmd是中文版的,则修改脚本如下:

@echo off
ping www.google.cn -n 1| find "来自">ip.txt
for /f "tokens=2-15 delims= " %%i in (ip.txt) do set googleip=%%i
echo %googleip%
findstr /e /v /r /c:"google.com" "C:\Windows\System32\drivers\etc\hosts">>hosts
echo %googleip% encrypted.google.com>>hosts
echo %googleip% docs.google.com>>hosts
echo %googleip% code.google.com>>hosts
echo %googleip% google.com>>hosts
copy hosts "C:\Windows\System32\drivers\etc\hosts" /y
del hosts /f  /q

保存执行即可!

ps:怎么知道自己的cmd是中文版还是英文版:例:
中文版ping:

来自 203.208.46.148 的回复: 字节=32 时间=38ms TTL=55

英文版ping:

Reply from 203.208.46.148: bytes=32 time=38ms TTL=55
7