一键更换hosts

利用powershell随便写的一些垃圾,小工具而已(。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
@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
echo.Choose the number:
echo.
echo. 1.change hosts (1)
echo.
echo. 2.reset hosts (2)
echo.-----------------------------------------------------------

set /p choice=Input number and press enter:

echo.
if %choice%==1 goto host DNS
if %choice%==2 goto CL
cls
"set choice="
echo input error!
ping 127.0.1 -n "2">nul
goto main


:host DNS
cls
copy /y "hosts" "%SystemRoot%\System32\drivers\etc\hosts"
ipconfig /flushdns
cls
echo. done
echo.
goto end

:CL
cls
@echo 127.0.0.1 localhost > %SystemRoot%\System32\drivers\etc\hosts
ipconfig /flushdns
cls
echo done
echo.
goto end

:end
echo Press any key to exit.
@Pause>nul