使用批處理替換windows系統中的hosts檔案

來源:互聯網
上載者:User

標籤:sts   重新整理   加密   輸入   choice   run   windows系統   amp   https   

chcp 936 >nul
@echo off
mode con lines=30 cols=60
%1 mshta vbscript:CreateObject("Shell.Application").ShellExecute("cmd.exe","/c %~s0 ::","","runas",1)(window.close)&&exit
cd /d "%~dp0"
:main
cls
color 0a
echo.警告:執行該命令 您的hosts將被自動替換覆蓋!
echo.如您原先的hosts有自己修改過的資訊,請自行手動修改!
echo.
echo.
echo.2017 永久更新地址:
echo.https://laod.cn/hosts/2017-google-hosts.html
color 0a
echo.-----------------------------------------------------------
echo.請選擇使用:
echo.
echo. 1.使用穿牆hosts(即在下面輸入1)
echo.
echo. 2.恢複初始hosts(即在下面輸入2)
echo.-----------------------------------------------------------

if exist "%SystemRoot%\System32\choice.exe" goto Win7Choice

set /p choice=請輸入數字並按斷行符號鍵確認:

echo.
if %choice%==1 goto host DNS
if %choice%==2 goto CL
cls
"set choice="
echo 您輸入有誤,請重新選擇。
ping 127.0.1 -n "2">nul
goto main

:Win7Choice
choice /c 12 /n /m "請輸入相應數字:"
if errorlevel 2 goto CL
if errorlevel 1 goto host DNS
cls
goto main

:host DNS
cls
color 0a
copy /y "hosts" "%SystemRoot%\System32\drivers\etc\hosts"
ipconfig /flushdns
echo.-----------------------------------------------------------
echo.
echo 阿臣恭喜您,覆蓋本地hosts並重新整理本地DNS解析緩衝成功!
echo.
echo 現在去開啟Google、Twitter、Facebook、Gmail、Google學術吧!
echo.
echo.Google這些網站記得使用https進行加密訪問!
echo.
echo.即:https://www.google.com
echo.
echo.或者:https://www.google.com/ncr
echo. https://www.google.com.hk/ncr
echo.
goto end

:CL
cls
color 2f
@echo 127.0.0.1 localhost > %SystemRoot%\System32\drivers\etc\hosts
echo 恭喜您,hosts恢複初始成功!
echo.
goto end

:end
echo 請按任意鍵退出。
@Pause>nul

使用批處理替換windows系統中的hosts檔案

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.