@echo off
title Setup TV Gateway for Samsung Smart TV
:: Check for Administrator privileges and self-elevate
net session >nul 2>&1
if %errorLevel% neq 0 (
echo Requesting Administrator privileges...
powershell -NoProfile -ExecutionPolicy Bypass -Command "Start-Process -FilePath '%~f0' -Verb RunAs"
exit /b
)
echo ========================================================
echo Configuring Windows PC as VPN Gateway for Smart TV
echo ========================================================
echo.
echo [1/5] Enabling IP Routing in Windows Registry...
reg add "HKLM\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters" /v IPEnableRouter /t REG_DWORD /d 1 /f
echo [2/5] Enabling Routing Service...
sc config RemoteAccess start= auto >nul 2>&1
net start RemoteAccess >nul 2>&1
echo [3/5] Enabling Packet Forwarding on Network Adapters...
powershell -NoProfile -Command "Get-NetIPInterface | Where-Object { $_.InterfaceAlias -like '*Ethernet*' -or $_.InterfaceAlias -like '*wwan*' } | ForEach-Object { Set-NetIPInterface -InterfaceIndex $_.InterfaceIndex -Forwarding Enabled -WeakHostReceive Enabled -WeakHostSend Enabled }"
echo [4/5] Opening Windows Firewall for LAN Proxy (Port 10808)...
netsh advfirewall firewall delete rule name="INCY_PROXY_LAN" >nul 2>&1
netsh advfirewall firewall add rule name="INCY_PROXY_LAN" dir=in action=allow protocol=TCP localport=10808 >nul 2>&1
netsh advfirewall firewall delete rule name="INCY_DNS_LAN" >nul 2>&1
netsh advfirewall firewall add rule name="INCY_DNS_LAN" dir=in action=allow protocol=UDP localport=53 >nul 2>&1
echo [5/5] Portproxy 10808 to 0.0.0.0...
netsh interface portproxy delete v4tov4 listenport=10808 listenaddress=0.0.0.0 >nul 2>&1
netsh interface portproxy add v4tov4 listenport=10808 listenaddress=0.0.0.0 connectport=10808 connectaddress=127.0.0.1 >nul 2>&1
echo.
echo ========================================================
echo [SUCCESS] Gateway configured successfully!
echo Local PC IP: 192.168.31.120
echo TV IP: 192.168.31.150
echo ========================================================
echo.
pause