hosts/disable-dnscache-service-wi...

44 lines
1.1 KiB
Batchfile
Raw Normal View History

2022-03-06 20:11:40 +01:00
@echo off
title Disable DNS Cache Service
:: Check if we are an administrator. If not, exit immediately.
2021-05-06 18:09:37 +02:00
:: BatchGotAdmin
2022-03-06 20:11:40 +01:00
:: Check for permissions
if "%PROCESSOR_ARCHITECTURE%" equ "amd64" (
>nul 2>&1 "%SYSTEMROOT%\SysWOW64\cacls.exe" "%SYSTEMROOT%\SysWOW64\config\system"
2022-03-06 20:11:40 +01:00
) else (
>nul 2>&1 "%SYSTEMROOT%\system32\cacls.exe" "%SYSTEMROOT%\system32\config\system"
2021-05-06 18:09:37 +02:00
)
2022-03-06 20:11:40 +01:00
:: If the error flag set, we do not have admin rights.
if %ERRORLEVEL% neq 0 (
echo Requesting administrative privileges...
goto UACPrompt
2022-03-06 20:11:40 +01:00
) else (
goto gotAdmin
2022-03-06 20:11:40 +01:00
)
2021-05-06 18:09:37 +02:00
:UACPrompt
2022-03-06 20:11:40 +01:00
echo Set UAC = CreateObject^("Shell.Application"^) > "%TEMP%\getadmin.vbs"
set params= %*
echo UAC.ShellExecute "cmd.exe", "/c ""%~s0"" %params:"=""%", "", "runas", 1 >> "%TEMP%\getadmin.vbs"
2021-05-06 18:09:37 +02:00
2022-03-06 20:11:40 +01:00
wscript.exe "%TEMP%\getadmin.vbs"
del "%TEMP%\getadmin.vbs"
exit /b
2021-05-06 18:09:37 +02:00
:gotAdmin
:SCset
:: VALUE
2021-05-06 18:09:37 +02:00
:: 2 (Automatic) (DEFAULT)
2022-03-06 20:11:40 +01:00
:: 4 (Disabled) (to prevent network freeze after applying a huge hosts file)
2021-05-06 18:09:37 +02:00
::
:: See https://superuser.com/a/1277960
::
2022-03-06 20:11:40 +01:00
reg add "HKLM\SYSTEM\CurrentControlSet\services\Dnscache" /v Start /t REG_DWORD /d 4 /f
echo Reboot your system now!
echo.
pause