The GUI wizard works, but a technician fixing ten PCs does not click through seven screens ten times. One netsh command creates the same block rule — and it can be pasted into a script or run in seconds.
Everything the firewall wizard does can be done from an administrator Command Prompt with netsh advfirewall. The command below creates the same outbound block rule as the GUI method — same effect, no clicking. Every command here is written exactly as you should type it: copy, paste, change the name and path, Enter.
Firewall commands are refused without elevation, so this step is not optional:
Paste this command, changing only the rule name and the program path:
netsh advfirewall firewall add rule name="Block MyApp" dir=out program="C:\Program Files\MyApp\MyApp.exe" action=block profile=any
dir=out — the rule controls connections the program starts (outbound)action=block — drop that traffic instead of allowing itprofile=any — the block applies on Domain, Private and Public networks alikeThe answer is a single word: Ok. The rule is live immediately.
Check the rule before you trust it:
netsh advfirewall firewall show rule name="Block MyApp"
The output lists the rule's direction, program path, profiles and action. Confirm Enabled: Yes, Direction: Out, Action: Block and that the program path is exactly right — a typo in the path creates a rule that silently blocks nothing.
Microsoft now recommends the PowerShell NetSecurity commands for new scripts. The same rule in PowerShell (run as administrator) is:
New-NetFirewallRule -DisplayName "Block MyApp" -Direction Outbound -Program "C:\Program Files\MyApp\MyApp.exe" -Action Block
To remove the netsh rule later, one command does it:
netsh advfirewall firewall delete rule name="Block MyApp"
Be careful: delete works by name, so if two rules share the same name, both are deleted. Give every rule a unique name.
If you set up the same blocks on many PCs — a classroom, an office, a family fleet — paste your add rule commands, one per line, into Notepad and save the file as block-apps.bat. Right-click it → Run as administrator on each machine and every rule is created in one pass. Keep the names in the script identical to the names in your delete commands, and removing the whole set later is the same trick in reverse.
netsh advfirewall commands still work fully in Windows 10 and 11 — and both methods create the very same rule.Watch the video for the visual version — same rule, created with mouse clicks, so you can compare both methods.
▶️ Watch Full VideoYou are in a normal Command Prompt. Close it and reopen with Run as administrator — firewall changes always need an administrator window.
Yes — change dir=out to dir=in. For stopping an app from reaching the internet, outbound is the rule that matters; inbound rules control connections that other computers start towards you.
No. Firewall rules apply the moment they are created. Just restart the app itself so it makes fresh connection attempts.