@echo off

title Optimize Time Wait

set uac="%temp%\uac.vbs"
>nul 2>&1 "%windir%\system32\cacls.exe" "%windir%\system32\config\system"
if '%errorlevel%' NEQ '0' (
    echo Set UAC = CreateObject^("Shell.Application"^) > %uac%
    echo UAC.ShellExecute "%~s0", "", "", "runas", 1 >> %uac%
    echo %uac%
    %uac%
    exit /b
)

if exist %uac% del %uac%
set key=HKLM\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters
reg add %key% /v TcpTimedWaitDelay /t reg_dword /d 1 /f > nul

echo The optimizing operation had been completed.
echo Press any key to reboot.
pause > nul
start /min shutdown -r -t 0

