The Wiert Corner – irregular stream of stuff

Jeroen W. Pluimers on .NET, C#, Delphi, databases, and personal interests

  • My badges

  • Twitter Updates

  • My Flickr Stream

  • Pages

  • All categories

  • Enter your email address to subscribe to this blog and receive notifications of new posts by email.

    Join 2,865 other followers

Archive for September 18th, 2015

Batch file to open a specific TCP port in Windows 7 / 2008 Server and up

Posted by jpluimers on 2015/09/18

Thanks to the answer by Kevin Richardson on How to open ports on Windows firewall through batch file, I wrote this batch file that uses the add command of the Netsh AdvFirewall Firewall Commands which requires Admin privileges to run:

:: open port (first argument passed to batch script, second argument is description)
net file 1>nul 2>nul
if '%errorlevel%' == '0' ( goto :gotPrivileges ) else ( goto :getPrivileges )
echo You need to be admin running with an elevated security token to run %0
goto :exit
netsh advfirewall firewall add rule name="Open Port %1 for %2" dir=in action=allow protocol=TCP localport=%1
exit /b


via: How to open ports on Windows firewall through batch file – Stack Overflow

Posted in Firewall, Infrastructure, Microsoft Surface on Windows 7, Power User, Windows, Windows 7, Windows 8, Windows 8.1, Windows Server 2008, Windows Server 2008 R2, Windows Server 2012, Windows Server 2012 R2 | Leave a Comment »

%d bloggers like this: