Created
September 1, 2022 01:39
-
-
Save kripul/9258e41d880980d0449a350d7fff6e68 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@ECHO OFF | |
cd.>%windir%\GetAdmin | |
if exist %windir%\GetAdmin (del /f /q "%windir%\GetAdmin") else ( | |
echo CreateObject^("Shell.Application"^).ShellExecute "%~s0", "%*", "", "runas", 1 >> "%temp%\Admin.vbs" | |
"%temp%\Admin.vbs" | |
del /f /q "%temp%\Admin.vbs" | |
exit /b 2) | |
rem set PORT=30120 | |
set /p PORT= what port do you want to add? : | |
set RULE_NAME="Open Port %PORT%" | |
netsh advfirewall firewall show rule name=%RULE_NAME% >nul | |
if not ERRORLEVEL 1 ( | |
rem Rule %RULE_NAME% already exists. | |
echo Hey, you already got a out rule by that name, you cannot put another one in! | |
) 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% | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment