WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

OLE COM ADO CDO ADSI LDAP
plus
plus
plus
plus
plus
plus
plus
plus
plus
plus
plus
plus
plus
plus
plus
plus
plus
plus
plus
plus
plus
plus
plus
plus
plus
plus
plus
plus
plus
plus
plus
plus
plus
plus
plus
plus
plus
plus
plus

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

Add Application to the Windows Firewall Exceptions List


Question:

Is there a way to programatically create an application exception in the XP SP2 firewall settings using winbatch?

Answer:

; Add IM to the Windows Firewall exceptions list - based on MSFT example.

; Set constants
NET_FW_PROFILE_DOMAIN = 0
NET_FW_PROFILE_STANDARD = 1

; Scope
NET_FW_SCOPE_ALL = 0

; IP Version – ANY is the only allowable setting for now
NET_FW_IP_VERSION_ANY = 2

; Create the firewall manager object.
fwMgr = CreateObject("HNetCfg.FwMgr")

; Get the current profile for the local firewall policy.
profile = fwMgr.LocalPolicy.CurrentProfile

app = CreateObject("HNetCfg.FwAuthorizedApplication")
sProgramFiles = Environment("PROGRAMFILES")
app.ProcessImageFileName = StrCat(sProgramFiles, "\Outlook Express\msimn.exe")
app.Name = "Outlook Express"
app.Scope = NET_FW_SCOPE_ALL

; Use either Scope or RemoteAddresses, but not both
;app.RemoteAddresses = "*"
app.IpVersion = NET_FW_IP_VERSION_ANY
app.Enabled = @TRUE

; Use this line if you want to add the app, but disabled.
;app.Enabled = @FALSE

profile.AuthorizedApplications.Add( app )

Article ID:   W17085
File Created: 2007:07:03:14:28:14
Last Updated: 2007:07:03:14:28:14