@echo off
rem DNS Client service stop/start
chcp 437

rem check DNS client service status
set ret=
for /f "delims=" %%a in ('sc query dnscache ^| findstr /C:STOPPED') do @set ret=%%a
if not "%ret%" == "" (
	echo DNS Client service already stopped.
	goto :START_DNSCACHE
)


rem DNS Client service stop
:STOP_DNSCACHE
echo DNS Client service stopping...
set ret=
for /f "delims=" %%a in ('net stop dnscache ^| findstr /C:success') do @set ret=%%a
if not "%ret%" == "" (
	echo SUCCESS
) else (
	echo msgbox "DNS Client service stop failed. This batch file needs an adminiatrator right to execute. Please check and try again." > %TEMP%/msgboxtest.vbs&%TEMP%/msgboxtest.vbs
	exit /B
)

rem confirm DNS client stopped
set ret=
for /f "delims=" %%a in ('sc query dnscache ^| findstr /C:STOPPED') do @set ret=%%a
if "%ret%" == "" (
	echo DNS Client service already started.
	exit /B
)

rem DNS Client service start
:START_DNSCACHE
set ret=
echo DNS Client service starting...
for /f "delims=" %%a in ('net start dnscache ^| findstr /C:success') do @set ret=%%a
if not "%ret%" == "" (
	echo SUCCESS
) else (
	echo msgbox "DNS Client service start failed.please try again." > %TEMP%/msgboxtest.vbs&%TEMP%/msgboxtest.vbs
	exit /B
)

