"netsh advfirewall firewall delete rule name program" syntax not work

2

not work:

netsh advfirewall firewall delete rule program="C\Program Files (x86)\utorrent\uTorrent.exe"

not work:

netsh advfirewall firewall delete rule name=program="C\Program Files (x86)\utorrent\uTorrent.exe"

not work:

netsh advfirewall firewall delete rule name program="C\Program Files (x86)\utorrent\uTorrent.exe"

not work

netsh advfirewall firewall delete rule name program "C\Program Files (x86)\utorrent\uTorrent.exe"

not work:

netsh advfirewall firewall delete rule name "program=C\Program Files (x86)\utorrent\uTorrent.exe"

and not work:

netsh advfirewall firewall delete rule name="program=C\Program Files (x86)\utorrent\uTorrent.exe"

What is the correct syntax for this?

I have Windows 7 Ultimate 64-bit.

Riccardo La Marca

Posted 2017-08-05T13:45:05.083

Reputation: 163

2You need to delete the rule "*name*" and not the program you are pointing the rule to ... For example --> netsh advfirewall firewall delete rule name="<Rule Name>" – Pimp Juice IT – 2017-08-05T13:49:30.017

Try running netsh advfirewall firewall show rule status=enabled name=all and this will show you a list of all the enabled rules you have setup. Find the "*name*" of the applicable rule for uTorrent and then rule the command like I listed in the above comment but with the rule name where that is supposed to be. – Pimp Juice IT – 2017-08-05T13:53:19.333

in the command guide there is the program parameter:

C:\Windows>netsh advfirewall firewall delete rule ?

Sintassi: delete rule name= [dir=in|out] [profile=public|private|domain|any[,...]] [program=] [service=|any] [localip=any||||| ] [remoteip=any|localsubnet|dns|dhcp|wins|defaultgateway| ||||] [localport=0-65535|[,...]|RPC|RPC-EPMap|any] [remoteport=0-65535|[,...]|any] [protocol=0-255|icmpv4|icmpv6|icmpv4:type,code|icmpv6:type,code| tcp|udp|any] – Riccardo La Marca – 2017-08-05T13:58:02.223

netsh advfirewall firewall show rule status=enabled name=all | FINDSTR Torrent
...........................................There is in rule. Now i try.
– Riccardo La Marca – 2017-08-05T14:08:22.477

Answers

1

I have found another powerfull solution:

@echo off
setlocal EnableExtensions DisableDelayedExpansion
REG EXPORT "HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\services\SharedAccess\Parameters\FirewallPolicy\FirewallRules" "%TEMP%\RegBackup.reg" /y > NUL 2> NUL
TYPE "%TEMP%\RegBackup.reg" | FINDSTR /i /v torrent > "%TEMP%\RegBackupNew.reg"
REG DELETE "HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\services\SharedAccess\Parameters\FirewallPolicy\FirewallRules" /f /va > NUL 2> NUL
REG IMPORT "%TEMP%\RegBackupNew.reg" 2> NUL
REG EXPORT "HKEY_LOCAL_MACHINE\SYSTEM\ControlSet002\services\SharedAccess\Parameters\FirewallPolicy\FirewallRules" "%TEMP%\RegBackup.reg" /y > NUL 2> NUL
TYPE "%TEMP%\RegBackup.reg" | FINDSTR /i /v torrent > "%TEMP%\RegBackupNew.reg"
REG DELETE "HKEY_LOCAL_MACHINE\SYSTEM\ControlSet002\services\SharedAccess\Parameters\FirewallPolicy\FirewallRules" /f /va > NUL 2> NUL
REG IMPORT "%TEMP%\RegBackupNew.reg" 2> NUL
DEL /q "%TEMP%\RegBackup.reg" 2> NUL
DEL /q "%TEMP%\RegBackupNew.reg" 2> NUL
endlocal

Riccardo La Marca

Posted 2017-08-05T13:45:05.083

Reputation: 163

I think your approach is too vast. Better were to export and filter with torrent and delete these keys, this ways leaving the majority of rules untouched. – LotPings – 2017-08-15T14:23:35.860

4

It seems you are trying to use the "Program" parameter and value rather than "Rule" name in the delete statement.

You can run netsh advfirewall firewall show rule status=enabled name=all or perhaps netsh advfirewall firewall show rule status=enabled name=all | FIND /I "uTorrent" to get a list of the rules that are enabled to help location the actual name of the rule.

Once this is determined, you can run netsh advfirewall firewall delete rule name="<Rule Name>" and plug the name of the rule in accordingly for it to remove that rule.

Examples

Create a rule with the name "IP Block"

netsh advfirewall firewall add rule name="IP Block" dir=in interface=any action=block remoteip=<IPaddress>/32

Delete a rule with the name "IP Block"

netsh advfirewall firewall delete rule name="IP Block"

Further Resources

Pimp Juice IT

Posted 2017-08-05T13:45:05.083

Reputation: 29 425

1

None of your attempts contains a correct rule name.

If not supplying a distinct rule name use (according to this help ) name=all in combination with program="C:\Program Files (x86)\utorrent\uTorrent.exe"

netsh advfirewall firewall delete rule name=all program="C:\Program Files (x86)\utorrent\uTorrent.exe"

name = { all | RuleName }
Required.  You can specify one of the following values:

  • The rule name of the connection security rule you want deleted.
  • all.  Specifies that all rules matching the criteria in the other parameters are deleted.  If no other parameters are included in the command then all connection security rules are deleted.

LotPings

Posted 2017-08-05T13:45:05.083

Reputation: 6 150

Thank you so much! I don't able cast positive vote, but this delete multiple rules in one shot and is much more affidable. But this not delete the voice in ...................HKEY_LOCAL_MACHINE\SYSTEM\ControlSet002\services\SharedAccess\Parameters\FirewallPolicy\FirewallRules. Why? – Riccardo La Marca – 2017-08-05T14:40:33.637

This works only on............HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\services\SharedAccess\Parameters\FirewallPolicy\FirewallRules.................and not for.............HKEY_LOCAL_MACHINE\SYSTEM\ControlSet002\services\SharedAccess\Parameters\FirewallPolicy\FirewallRules............................Not work on: ControlSet002............................Work on: ControlSet001 – Riccardo La Marca – 2017-08-05T14:51:16.130

AFIK the currentcontrolset is mapped to only one of the controlsets. Cite from this Q&A: you only need to update the CurrentControlSet key... ControlSet001 and ControlSet002 are alternating backups of CurrentControlSet, you don't need to update them. The other key is kept as a backup for the Load Last Known Good Configuration boot option.

– LotPings – 2017-08-05T14:54:58.677

How is update backup of controlset002? – Riccardo La Marca – 2017-08-05T15:19:40.797

How do I upgrade controlset002?* – Riccardo La Marca – 2017-08-05T15:25:06.157

Don't interfere with the windows mechanisms. The other controlset represents a former consistent state of your installation. It doesn't make sense to tamper with this consitency by loading this hive and manipulating it. So don't update it – LotPings – 2017-08-05T15:25:07.297

Try at restart my sistem. – Riccardo La Marca – 2017-08-05T15:26:33.503

ControlSet002 has been updated automatically after the system restarts. How can I avoid restarting windows to update it automatically? – Riccardo La Marca – 2017-08-05T15:40:11.577

I don't understand that request, you want to update but not on a reboot? You should completely ignore the ControlSet00x and only refer to the CurrentControlSet – LotPings – 2017-08-05T15:45:02.237

currentcontrolset link only controlset001 and not controlset002. Delete uTorrent from firewall for controlSet002 happens only if I restart the system and only if utorrent is not present on ControlSet001. Is there a way to do it avoiding reboot the system? – Riccardo La Marca – 2017-08-05T15:47:28.430