Block applications from accessing the Internet with GUI is easy. simply go to the Start menu and search for Firewall & Network protection. From the dialogue box, click on Domain Network and turn the Firewall Off. Likewise, you have to turn off the firewall for Private Network and Public Network. In case you need to turn off the firewall only for the Internet, turn off the Firewall only for Public Network.
Disable Windows Firewall With Command Line
However, if you are like me who prefer to disable Windows firewall with the command line, here’s a quick way to do it on Windows 10 and 7. Open up the command prompt. Go to the Start menu, type Command Prompt. Right click on it and select Run as Administrator. This command to disable Firewall needs elevated permissions, so it needs to be run as an administrator.
On the command prompt, Type This will turn off the firewall for all 3 networks. To turn it back on, replace off with on.
Much like the terminal in macOS and Linux, Windows cmd also lets you move through your last used commands using the up and down arrows on your keyboard. So, if you wanted to previous last command you ran, just hit the up arrow once, edit the command (change off to on) and hit Enter.
Block Any App in the firewall (Command Line)
To block any app in the firewall, we first need to understand what is the inbound and the outbound rule. Inbound rules are defined to either block/allow the app from receiving data on your computer. Outbound rules are defined to either block/allow the application to send data from your computer. To block any in Firewall using GUI is easy. All you have to do is go to the Firewall & Network Protection. Click Advanced Settings and go to the Outbound rules tab. Click on New Rule on the right-hand side of the window. Select Rule Type as Program from the pop-up. Click on Next and further steps like specifying program path are self-explanatory. However, doing the same with the command prompt is not that intuitive. First, you need to decide whether you need to block the app from receiving or sending data from the Internet. Say, you want to block Chrome app from accessing the Internet. Next, we need to find the location of the .exe file in our system. Usually, it should be in C:\Program Files, unless you have defined it manually. Go to the .exe file and copy the path name. In my case for google chrome, the path would be : Once you have the file location, all you have to do is open Command Prompt with administrator privilege and type the following command :
Now when I open chrome, internet access is disabled.
Block Any App in the Firewall with its Port Number
In case you want to block the app by port number. First, you have to identify the port number. To do that, go to Start menu and type Resource Monitor. Right click on it and select Run as Administrator.
Once the dialogue box opens, go to the Network tab and expand the Listening Ports section by clicking on it.
Once you have the port number use the following command to block that particular port.
If you are not sure about the exact port number you can also choose to block a range of ports by specifying port=1000-2000. To delete this outbound rule, type the below give command with the name of the rule you have specified earlier.
This should fix things and Chrome should be able to access the Internet.
Wrapping Up
These methods enable you to block any particular application from accessing the Internet. This can be used against fishy apps to protect your data from being sent over to private networks or the Internet. If you have any problems with the step, you can comment the error and I can help you out with the solution. Read: How to Reset TCP/IP in Windows, Linux, and macOS