?
Solved

Open ports in XP SP2 Firewall with Vb6?

Posted on 2005-03-11
3
Medium Priority
?
388 Views
Last Modified: 2010-04-17
Code examples?  Can this be changed in the registry?  I install my program as domain admin need it to open the ports it needs on install WITH vb6 code please.  Thanks!
0
Comment
Question by:bluedragon99
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 8

Accepted Solution

by:
jkorz earned 2000 total points
ID: 13519327
Option Explicit
On Error GoTo 0

'Set Constants
Const NET_FW_IP_PROTOCOL_UDP = 17
Const NET_FW_IP_PROTOCOL_TCP = 6

Const NET_FW_SCOPE_ALL = 0
Const NET_FW_SCOPE_LOCAL_SUBNET = 1

'Declare variables
Dim errornum

' Create the firewall manager object.
Dim fwMgr
Set fwMgr = CreateObject("HNetCfg.FwMgr")

' Get the current profile for the local firewall policy.
Dim profile
Set profile = fwMgr.LocalPolicy.CurrentProfile

Dim port
Set port = CreateObject("HNetCfg.FWOpenPort")

port.Name = “HTTP”
port.Protocol = NET_FW_IP_PROTOCOL_TCP
port.Port = 80

‘If using Scope, don’t use RemoteAddresses
port.Scope = NET_FW_SCOPE_ALL
‘Use this line to scope the port to Local Subnet only
‘port.Scope = NET_FW_SCOPE_LOCAL_SUBNET

port.Enabled = TRUE
‘Use this line instead if you want to add the port, but disabled
‘port.Enabled = FALSE

On Error Resume Next
profile.GloballyOpenPorts.Add port
errornum = Err.Number

If errornum <> 0 Then
    WScript.Echo("Adding the port failed. Error Number: " & errornum)
End If
0
 
LVL 8

Expert Comment

by:jkorz
ID: 13519338
Forgot to mention the code was in vbscript... should be able to port to vb6 pretty easily
0
 
LVL 1

Author Comment

by:bluedragon99
ID: 13519376
Looks good, i'll try to convert...
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

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

This is about my first experience with programming Arduino.
In this post we will learn different types of Android Layout and some basics of an Android App.
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…
Simple Linear Regression

764 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