Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Add SQL Server Port to exceptions in Windows Firewall from vb.net

Posted on 2012-03-28
4
Medium Priority
?
661 Views
Last Modified: 2012-04-02
I'm looking for a way to get the Port number SQL server is running on (if possible)
and then add that port as an exception to the windows firewall for a VB.net application.
0
Comment
Question by:koossa
  • 3
4 Comments
 
LVL 5

Expert Comment

by:Apothis
ID: 37776579
SQL Server is a Winsock application that communicates over TCP/IP by using the sockets network library. SQL Server listens for incoming connections on a particular port. The default port for SQL Server is 1433. The port doesn't need to be 1433, but 1433 is the official Internet Assigned Number Authority (IANA) socket number for SQL Server.

Gathered from here:

http://support.microsoft.com

Hope that's what you were looking for.
0
 

Author Comment

by:koossa
ID: 37777517
Hi

I know what the port is, but what I'm looking for is from Visual basic .net, how do I add this port to the firewall's exception list.
In other word, I want to write a piece of code that adds port 1433 to the exception list.
0
 

Accepted Solution

by:
koossa earned 0 total points
ID: 37777636
Ok, I found it:
    Dim objFirewall As Object
    Dim objPolicy As Object
    Dim objPort As Object
    Dim colPorts As Object
    objFirewall = CreateObject("HNetCfg.FwMgr")
    objPolicy = objFirewall.LocalPolicy.CurrentProfile

    objPort = CreateObject("HNetCfg.FwOpenPort")
    objPort.Port = 1433
    objPort.Name = "SQL Server"
    objPort.Enabled = True
    colPorts = objPolicy.GloballyOpenPorts

    Call colPorts.Add(objPort)

Open in new window

0
 

Author Closing Comment

by:koossa
ID: 37795131
Correct
0

Featured Post

Veeam Task Manager for Hyper-V

Task Manager for Hyper-V provides critical information that allows you to monitor Hyper-V performance by displaying real-time views of CPU and memory at the individual VM-level, so you can quickly identify which VMs are using host resources.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In my previous article (http://www.experts-exchange.com/Programming/Languages/.NET/.NET_Framework_3.x/A_4362-Serialization-in-NET-1.html) we saw the basics of serialization and how types/objects can be serialized to Binary format. In this blog we wi…
More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
This course is ideal for IT System Administrators working with VMware vSphere and its associated products in their company infrastructure. This course teaches you how to install and maintain this virtualization technology to store data, prevent vuln…
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…
Suggested Courses

916 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question