Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

Open ports in XP SP2 Firewall with Vb6?

Posted on 2005-03-11
3
Medium Priority
?
399 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
  • 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

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

Create a Windows 10 custom Image with custom task bar and custom start menu using XML for deployment.
What do responsible coders do? They don't take detrimental shortcuts. They do take reasonable security precautions, create important automation, implement sufficient logging, fix things they break, and care about users.
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
Progress

571 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