The Wiert Corner – irregular stream of stuff

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

  • My badges

  • Twitter Updates

    • @Voersterin Wie mein Toilettenbesuch dann sehr lang ist (normalerweise jede 1.5 Stunden kurz). Grrrrrrrr. 2 minutes ago
    • RT @WIRED: The Apple II computer ceased production in 1993, but that hasn’t stopped fans from continuing to create new programs for it http… 3 hours ago
    • RT @chrisklomp: Dat zeg ik. Dit zijn geen demonstranten. Dit is tuig. 3 hours ago
    • RT @ginnymooy: Oh ah ok. Dus dít zijn de jongeren voor wie een kwart van de bevolking zich maar eindeloos moet isoleren, het 'dor hout op t… 3 hours ago
    • RT @christogrozev: Finally, an official confirmation to our data-driven investigation last summer that proved Jan Marsalek defected to Bel… 3 hours ago
  • 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,230 other followers

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)
:checkPrivileges
net file 1>nul 2>nul
if '%errorlevel%' == '0' ( goto :gotPrivileges ) else ( goto :getPrivileges )
:isNotAdmin
:getPrivileges
echo You need to be admin running with an elevated security token to run %0
goto :exit
:isAdmin
:gotPrivileges
netsh advfirewall firewall add rule name="Open Port %1 for %2" dir=in action=allow protocol=TCP localport=%1
:exit
::pause
exit /b

–jeroen

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

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.

 
%d bloggers like this: