28 lines
1.0 KiB
Batchfile
28 lines
1.0 KiB
Batchfile
@echo off
|
|
rem ==================================================================
|
|
rem Opens Windows Firewall so OTHER PCs on the network can reach the
|
|
rem portal. The port is read automatically from .env (PORT=...),
|
|
rem falling back to 5000. >> RUN AS ADMINISTRATOR
|
|
rem Re-run this after changing PORT in .env (old rule is replaced).
|
|
rem ==================================================================
|
|
net session >nul 2>&1
|
|
if %ERRORLEVEL% NEQ 0 (
|
|
echo This script must be run as Administrator.
|
|
pause
|
|
exit /b 1
|
|
)
|
|
|
|
set "PORT=5000"
|
|
if exist "%~dp0..\.env" (
|
|
for /f "tokens=2 delims==" %%P in ('findstr /b /i "PORT=" "%~dp0..\.env"') do set "PORT=%%P"
|
|
)
|
|
rem strip possible spaces
|
|
set "PORT=%PORT: =%"
|
|
|
|
echo Using port: %PORT%
|
|
netsh advfirewall firewall delete rule name="SAP-ERP-Portal" >nul 2>&1
|
|
netsh advfirewall firewall delete rule name="SAP-ERP-Portal 5000" >nul 2>&1
|
|
netsh advfirewall firewall add rule name="SAP-ERP-Portal" dir=in action=allow protocol=TCP localport=%PORT%
|
|
echo Firewall rule added for TCP port %PORT%.
|
|
pause
|