hostsファイルを変更します.batバッチファイル解釈

2879 ワード

::コメントを表示し、使用時にコメントを削除
@echo off
mode con lines=30 cols=60          ::        30 60 
%1 mshta vbscript:CreateObject("Shell.Application").ShellExecute("cmd.exe","/c %~s0 ::","","runas",1)(window.close)&&exit                ::         cmd,  runas      ,       
cd /d "%~dp0"                     ::cd  /d        :\   ,"%~dp0"             
:main
cls                               ::  
color 2f                           ::    
echo √√    √√  √√√      √√√√  √√√√√    √√√√
echo   √    √  √      √  √      √  √  √  √  √      √
echo   √    √  √      √  √              √      √
echo   √√√√  √      √    √√          √        √√
echo   √    √  √      √        √        √            √
echo   √    √  √      √          √      √              √
echo   √    √  √      √  √      √      √      √      √
echo √√    √√  √√√    √√√√      √√√    √√√√
echo.----------------------------------------------------------- 
echo.  360、           ,            !
echo.
echo.  :        hosts        !
echo.     hosts         ,       !
echo.
echo. D   https://laod.cn      :laod.org laod.top
echo.
echo.2017       :
echo.https://laod.cn/hosts/2017-google-hosts.html
color 2e
echo.-----------------------------------------------------------
echo.     :
echo.
echo. 1.    hosts(      1)
echo.
echo. 2.    hosts(      2)
echo.-----------------------------------------------------------

if exist "%SystemRoot%\System32\choice.exe" goto Win7Choice
::            Win7Choice   choice.exe,        
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            ::    1    
goto main

:Win7Choice
choice /c 12 /n /m "       :"          ::/c          ,         1 2
if errorlevel 2 goto CL                ::   2   CL
if errorlevel 1 goto host DNS 
cls
goto main

:host DNS
cls
color 2f
copy /y "hosts" "%SystemRoot%\System32\drivers\etc\hosts"         ::/y                   
ipconfig /flushdns                                       ::  DNS  
echo.-----------------------------------------------------------
echo.
echo  D   ,    hosts     DNS      !
echo.
echo      Google、Twitter、Facebook、Gmail、     !
echo.
echo.          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       :: 127.0.0.1  localhost    hosts          hosts    
echo    ,hosts      !
echo.
goto end

:end
echo        。
@Pause>nul          ::>nul              

PS:参照リンク:バッチ|hosts.Bat詳細バッチ|hosts.bat詳細(Googleスナップショット)コマンドはスクリプトの先頭に書き、管理者IDを呼び出してスクリプトを実行するchoice詳細shellExecuteの使い方を実現します.