-
-
Notifications
You must be signed in to change notification settings - Fork 160
/
windows-update-hosts.bat
41 lines (30 loc) · 1.4 KB
/
windows-update-hosts.bat
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
:: ULTIMATE HOSTS BLACKLIST
:: REPO: https://github.com/Ultimate-Hosts-Blacklist/Ultimate.Hosts.Blacklist
:: Copyright (c) 2020 Ultimate Hosts Blacklist - @Ultimate-Hosts-Blacklist
:: Copyright (c) 2017, 2018, 2019, 2020 Mitchell Krog - @mitchellkrogza
:: Copyright (c) 2017, 2018, 2019, 2020 Nissar Chababy - @funilrys
:: This script will first create a backup of the original or current hosts
:: file and save it in a file titled "hosts.bak"
:: It will then download the latest updated hosts file
:: Finally the DNS cache will also be refreshed.
:: THIS BAT FILE MUST BE LAUNCHED WITH ADMINISTRATOR PRIVILEGES
:: @ECHO OFF
TITLE Update Hosts
:: Check if we are administrator. If not, exit immediately.
>nul 2>&1 "%SYSTEMROOT%\system32\cacls.exe" "%SYSTEMROOT%\system32\config\system"
if %ERRORLEVEL% NEQ 0 (
ECHO This script must be run with administrator privileges!
ECHO Please launch command prompt as administrator. Exiting...
EXIT /B 1
)
:: Download Latest Updated Hosts File
:: Uses a Windows component called BITS
:: It has been included in Windows since XP and 2000 SP3
bitsadmin.exe /transfer "Download Fresh Hosts File" https://hosts.ubuntu101.co.za/hosts.windows C:\tmp\hosts
echo Move new hosts file in-place
:: Move new hosts file in-place
COPY C:\tmp\hosts %WINDIR%\System32\drivers\etc\
echo Flush the DNS cache
:: Flush the DNS cache
ipconfig /flushdns
echo ALL DONE !!! Enjoy the Protection !!