@ECHO OFF set PORT=1433 set RULE_NAME="Open Port %PORT% TCP" netsh advfirewall firewall show rule name=%RULE_NAME% >nul if not ERRORLEVEL 1 ( echo Rule %RULE_NAME% already exists ) else ( echo Rule %RULE_NAME% does not exist. Creating... netsh advfirewall firewall add rule name=%RULE_NAME% dir=in action=allow protocol=TCP localport=%PORT% ) set PORT=1433 set RULE_NAME="Open Port %PORT% UDP" netsh advfirewall firewall show rule name=%RULE_NAME% >nul if not ERRORLEVEL 1 ( echo Rule %RULE_NAME% already exists ) else ( echo Rule %RULE_NAME% does not exist. Creating... netsh advfirewall firewall add rule name=%RULE_NAME% dir=in action=allow protocol=UDP localport=%PORT% ) pause