PHP User Warning: fetch_template() calls should be replaced by the vB_Template class. Template name: bbcode_highlight in ..../includes/functions.php on line 4197
Remove or delete firewall rule in windows xp problem (vb6 approach)-VBForums
Results 1 to 4 of 4

Thread: Remove or delete firewall rule in windows xp problem (vb6 approach)

  1. #1

    Thread Starter
    Member
    Join Date
    Feb 2019
    Posts
    43

    Remove or delete firewall rule in windows xp problem (vb6 approach)

    Good day.

    I have posted also in vb.net about this problem for vb.net approach.

    I have a vb.net code that remove a firewall rule by its rule name and it is working in windows 7 and above but it is not working in windows xp. I used HNetCfg.FwPolicy2 and the firewallapi.dll for the code.

    When I run the program on windows xp, it will throw error "VALUE CANNOT BE NULL. PARAMETER NAME: TYPE".

    I have already searched on google for days but exact answer. If vb.net dont have this answer, I am hoping vb6 have.

  2. #2
    Frenzied Member wqweto's Avatar
    Join Date
    May 2011
    Posts
    1,682

    Re: Remove or delete firewall rule in windows xp problem (vb6 approach)

    This VBScript works on XP
    thinBasic Code:
    1. RemoveRule = "Test" ' Use "sqlservr.exe" for application
    2. If RemoveFirewallRules(RemoveRule) Then
    3.     WScript.echo "Rule '" & RemoveRule & "' removed successfully"
    4. End If
    5. WScript.echo "Done."
    6.  
    7. Private Function RemoveFirewallRules(RuleName)
    8.     With CreateObject("HNetCfg.FwMgr").LocalPolicy.CurrentProfile
    9.         For Each vElem In .GloballyOpenPorts
    10.             If vElem.Name = RuleName Then
    11.                 .GloballyOpenPorts.Remove vElem.Port, vElem.Protocol
    12.                 RemoveFirewallRules = True
    13.                 Exit Function
    14.             End If
    15.         Next
    16.         For Each vElem In .AuthorizedApplications
    17.             If vElem.Name = RuleName Then
    18.                 .AuthorizedApplications.Remove vElem.ProcessImageFileName
    19.                 RemoveFirewallRules = True
    20.                 Exit Function
    21.             End If
    22.         Next
    23.     End With
    24. End Function
    cheers,
    </wqw>

  3. #3

    Thread Starter
    Member
    Join Date
    Feb 2019
    Posts
    43

    Re: Remove or delete firewall rule in windows xp problem (vb6 approach)

    thanks wqweto. I tried that it is working using vbscript but when I put it on vb.net app, it doesnt work. can you assist me further?

  4. #4
    Frenzied Member wqweto's Avatar
    Join Date
    May 2011
    Posts
    1,682

    Re: Remove or delete firewall rule in windows xp problem (vb6 approach)

    Quote Originally Posted by techbee View Post
    thanks wqweto. I tried that it is working using vbscript but when I put it on vb.net app, it doesnt work. can you assist me further?
    You can try posting the script in .Net sub-forum if someone can help re-implementing it in .Net. Here most people are able translating it to VB6 only.

    cheers,
    </wqw>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Featured


Click Here to Expand Forum to Full Width