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

Solution 1:

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

  • NETSH
  • Using NETSH

Solution 2:

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.

Solution 3:

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