@echo off
:: BatchGotAdmin
::-------------------------------------
REM  --> Check for permissions
>nul 2>&1 "%SYSTEMROOT%\system32\cacls.exe" "%SYSTEMROOT%\system32\config\system"

REM --> If error flag set, we do not have admin.
if '%errorlevel%' NEQ '0' (
    echo Requesting administrative privileges...
    goto UACPrompt
) else ( goto gotAdmin )

:UACPrompt
    echo Set UAC = CreateObject^("Shell.Application"^) > "%temp%\getadmin.vbs"
    set params = %*:"="
    echo UAC.ShellExecute "cmd.exe", "/c %~s0 %params%", "", "runas", 1 >> "%temp%\getadmin.vbs"

    "%temp%\getadmin.vbs"
    del "%temp%\getadmin.vbs"
    exit /B

:gotAdmin
    pushd "%CD%"
    CD /D "%~dp0"
::--------------------------------------
::ENTER YOUR CODE BELOW:
@echo off

rem 2_restore_hosts.cmd
if exist C:\windows\system32\drivers\etc\hosts.bak (
    move /Y C:\windows\system32\drivers\etc\hosts.bak C:\windows\system32\drivers\etc\hosts && ECHO DONE ------ restored hosts file
) else (
    ECHO CHECK ------ The back-up doesn't exist
)

rem back-up and replace hosts file
if exist C:\windows\system32\drivers\etc\hosts.bak (
    ECHO PASS ------ the original hosts file already exists
) else (
    copy /Y C:\windows\system32\drivers\etc\hosts C:\origin_hosts && ECHO DONE ------ backed up the original hosts file 
)
copy /Y C:\windows\system32\drivers\etc\hosts C:\windows\system32\drivers\etc\hosts.bak && ECHO DONE ------ backed up original hosts file
echo. >> C:\windows\system32\drivers\etc\hosts

echo 211.221.48.161 onboard.hinavi.hmm21.com >> C:\windows\system32\drivers\etc\hosts && ECHO DONE ------ replaced hosts to hmpg_hosts

ECHO DONE

timeout /t 10