Quantcast
Channel: VBForums - Visual Basic 6 and Earlier
Viewing all articles
Browse latest Browse all 21246

[RESOLVED] How to add program to the Windows Firewall exception list (Profile: All) ?

$
0
0
At the moment I use this code to add my program to the Windows Firewall exception list:

Code:

Option Explicit

Public Function AddToFirewallExceptions(ProgramAddress As String, ProgramName As String)

Const NET_FW_SCOPE_ALL = 0
Const NET_FW_IP_VERSION_ANY = 2
Dim appAuth As Object

On Error Resume Next

With CreateObject("HNetCfg.FwMgr")
Set appAuth = CreateObject("HNetCfg.FwAuthorizedApplication")
With appAuth
.ProcessImageFileName = ProgramAddress
.Name = ProgramName
.Scope = NET_FW_SCOPE_ALL
.IpVersion = NET_FW_IP_VERSION_ANY
.Enabled = True
End With

.LocalPolicy.CurrentProfile.AuthorizedApplications.Add appAuth

Set appAuth = .LocalPolicy.CurrentProfile.AuthorizedApplications.Item(ProgramAddress)
End With

If Err Then

Exit Function

End If
   
End Function

The problem is that if I run this code while there is an internet connection, in Windows Firewall exception list my program will get permission only for Private Network (Profile: Private). And if I run this code while there is no internet connection, in Windows Firewall exception list my program will get permission only for Public Network (Profile: Public). How can my program get access to the All Networks (Profile: All) ?

Viewing all articles
Browse latest Browse all 21246

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>