Windows 10: Need help trying to add a firewall rule for an application...

Discus and support Need help trying to add a firewall rule for an application... in AntiVirus, Firewalls and System Security to solve the problem; I have been trying to get this to work for almost a week now and I'm not having any luck. And as I've mentioned before, I'm not that great at vbscript.... Discussion in 'AntiVirus, Firewalls and System Security' started by jumper77, Jan 31, 2019.

  1. jumper77 Win User

    Need help trying to add a firewall rule for an application...


    I have been trying to get this to work for almost a week now and I'm not having any luck. And as I've mentioned before, I'm not that great at vbscript. When I step through the vb.net part of the code, it looks like it should work, but it's not. I could REALLY use some help because once I understand this part, I think I'm home free...

    First, here's my vb.net sub that does the work..
    Code: Private Sub AllowProgramAccess(FilePath As String, filename As String) Dim AppPath As String = Application.StartupPath Dim AddTarget As String = AppPath & "\AddRule.exe" Dim BlockTarget As String = AppPath & "\BlockProgram.exe" Dim startInfo As New ProcessStartInfo If AllowAccess Then startInfo.FileName = AddTarget Else startInfo.FileName = BlockTarget End If Dim args(1) As String args(0) = filename args(1) = FilePath startInfo.Arguments = args(0) & " " & args(1) startInfo.UseShellExecute = False startInfo.RedirectStandardOutput = True startInfo.CreateNoWindow = True Try Dim p As Process = Process.Start(startInfo) p.WaitForExit() If AllowAccess Then MsgBox("Added: " & filename & " to Whitelist") Else MsgBox(filename & " removed from Whitelist") End If Catch ex As Exception MsgBox(ex.Message) End Try Visible = False AllowAccess = False End Sub[/quote] AddRule.exe and BlockProgram,exe are just compiled vbscript code. Also, I was not using args(0) and args(1) until recently. Before I was just adding the FileName and Filepath to startInfo.Arguments.
    Here the first file (AddRule.vbs), before it was compiled...
    Code: dim Param1,Param2 param1 = wscript.arguments(0) param2 = wscript.arguments(1) Set objShell = WScript.CreateObject("WScript.Shell") objshell.run "%comspec% /c ""netsh advfirewall add rule name=Param1 dir=in program=param2 security=authenticate action=allow"" ", 0, True Set objShell = nothing[/quote] I'm guessing I'm not passing the parameters right.
    Here's the BlockProgram.vbs file...
    Code: Dim args, strOutOne, strOutTwo set args = Wscript.arguments If WScript.Arguments.Count <> 0 Then WScript.Echo "Missing parameters" End if strOutOne = args(0) strOutTwo = args(1) WScript.Echo strOutOne WScript.Echo strOutTwo Set objShell = WScript.CreateObject("WScript.Shell") objshell.run "%comspec% /c ""netsh advfirewall firewall delete rule name=strOutTwo"" ", 0, True" set objShell = nothing[/quote] Don't know why I'm using two paramets because I think you only need one to remove a rule. Plus, as I look at this, I think I'm passing the wrong parameter, lol

    I'm using the FileName as the rule name.
    If someone could help me fix this, I promise to dance at your wedding!!
    Thanks in advance for any help. It is truly appreciated!

    :)
     
    jumper77, Jan 31, 2019
    #1

  2. Windows 10 Firewall won't keep my inbound/outbound rules

    Hi,

    I realize the inconvenience caused to you regarding the Windows Firewall. I will certainly assist you.

    I suggest you to restart the Windows firewall service and check if it helps.

    Follow the below steps for the same.

    • Press Windows key + R simultaneously for Run.
    • Type services.msc and then Enter.
    • Right click on the Windows firewall services and then restart the services and check if it helps.
    If the issue still persists then I suggest you to remove and then read the Windows fire wall rule.

    Hope this information is helpful. Please get back to us with the information required, if you need further assistance, we’ll be glad to assist you.
     
    Anup Karkal, Jan 31, 2019
    #2
  3. mike1127 Win User
    firewall rule to block addresses NOT on an IP list?


    I am just starting to learn the Windows Firewall (working on both Windows 7 and 10) and I'm not impressed with the inflexibility of its rules. I would like to know if


    1. Is there is a way to do what I want with Windows Firewall?
    2. Is there is a third-party firewall that would do it?


    What I want to do is create a rule that blocks outgoing connections, for program X, that are to a destination **NOT** in an IP list.


    Windows Firewall is not very flexible in how you specify IP list rules. When you give an IP list, your rule will match that list... you can't say "trigger the rule for non-matching IP addresses." Therefore to allow outgoing connections to a list, you have to


    1. Change the entire firewall policy to block outgoing connections by default so that you can create an "allow rule" matching your list. This will mess up the rest of your programs.


    2. Somehow combine a block rule and allow rule. Create a block rule for most traffic, with the "allow" rule overriding it when appropriate. However, this doesn't appear to be possible in general. It **may** be possible for connections that use IPSec, I'm not sure. And I'm not sure if I can use IPSec in my application.

    And is there a third-party firewall that can do it? Most 3rd-party firewalls are LESS sophisticated than Windows Firewall, because the use case they are addressing is providing an interface that doesn't require much comprehension. I need one that's actually MORE sophisticated than Windows Firewall.
     
    mike1127, Jan 31, 2019
    #3
  4. TwuTu Win User

    Need help trying to add a firewall rule for an application...

    Windows Firewall: Doesn't show blocking rules

    Hello!

    Today I've blocked all connections of a program by creating a outbound rule in Windows Firewall. However, I now wish to remove it. The problem: I can't find that newly created rule anywhere in the list. The rule does take an effect, since deactivating the
    Firewall lets the program run properly. I can only see rules in the list that "allow" stuff, but not those who block things.

    What I have tried so far:

    - All filters set to "Show all" within the Firewall

    - Created the same rule again, doesn't show up

    - Created a rule that allows the program, shows up

    Any solutions?
     
    TwuTu, Jan 31, 2019
    #4
Thema:

Need help trying to add a firewall rule for an application...

Loading...
  1. Need help trying to add a firewall rule for an application... - Similar Threads - Need help trying

  2. Disable network multiplexor or add local firewall rules

    in Windows 10 Gaming
    Disable network multiplexor or add local firewall rules: I inherited a remote machine at work. It is a Windows server 2016It has the Windows Network Multiplexor Adapter applied and utilizes two network portsHow can I disable or modify it so that I can add local firewall rulesI have tried adding firewall rules but whatever rules I...
  3. Add Store apps to Windows Firewall outbound rule

    in Windows 10 Gaming
    Add Store apps to Windows Firewall outbound rule: Hello,I have changed Windows Firewall to block outbound connections.I had no problem configuring outbound rules to allow classic applications accessing the internet.I have tried adding the following two rules, but it does not...
  4. Add Store apps to Windows Firewall outbound rule

    in Windows 10 Software and Apps
    Add Store apps to Windows Firewall outbound rule: Hello,I have changed Windows Firewall to block outbound connections.I had no problem configuring outbound rules to allow classic applications accessing the internet.I have tried adding the following two rules, but it does not...
  5. Add Store apps to Windows Firewall outbound rule

    in Microsoft Windows 10 Store
    Add Store apps to Windows Firewall outbound rule: Hello,I have changed Windows Firewall to block outbound connections.I had no problem configuring outbound rules to allow classic applications accessing the internet.I have tried adding the following two rules, but it does not...
  6. Right Click - Add Inbound/Outbound Firewall Rule?

    in Windows 10 Ask Insider
    Right Click - Add Inbound/Outbound Firewall Rule?: Hi guys, I've always wondered why isn't there an option to quickly add an inbound/outbound firewall rule to an application straight from the app by, say, right click menu, add instantly? Wouldn't this be a great feature to have? Why the need to go to that Windows Defender...
  7. Firewall rules

    in Windows 10 Network and Sharing
    Firewall rules: [ATTACH] Does this symbol mean I have blocked outbound traffic for an application? If so why did the app just check for an update and confirm its current version? https://answers.microsoft.com/en-us/windows/forum/all/firewall-rules/870791a0-328a-4d5c-ad0a-be99f93dfdb0
  8. Firewall Rules

    in Windows 10 Network and Sharing
    Firewall Rules: Can you setup exceptions for firewall rules? For example, if I have a port blocked inbound for ALL via GPO, can I create an exception to that rule to allow just certain IP addresses to get through the port being blocked? Win 10 ENT in a domain environment....
  9. Need help to create firewall rule for forwarder using netsh command

    in Windows 10 Network and Sharing
    Need help to create firewall rule for forwarder using netsh command: I have created forwarder rule in windows to route the traffic coming from any user to loopback address 127.0.0.1 and forward it to another IP address. example: netsh interface portproxy add v4tov4 listenaddress=127.0.0.1 listenport=9000 connectaddress=127.0.0.8...
  10. Firewall rules

    in AntiVirus, Firewalls and System Security
    Firewall rules: I accidentally deleted outbound windows firewall rules. Will these reappear? Can this be dangerous? Please help. Thanks https://answers.microsoft.com/en-us/windows/forum/windows_10-security/firewall-rules/1f7cbdda-d9e2-435a-96cb-6caef7699b88"