-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
821 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
using System; | ||
using System.Collections; | ||
using System.IO; | ||
using System.Text.RegularExpressions; | ||
using NetFwTypeLib; | ||
|
||
namespace FirewallCleanup | ||
{ | ||
class FWIfz | ||
{ | ||
String pattern = @"\b[c-zC-Z]:\\"; | ||
|
||
public FWIfz() | ||
{ | ||
int counter = 0; | ||
Type tNetFwPolicy2 = Type.GetTypeFromProgID("HNetCfg.FwPolicy2"); | ||
INetFwPolicy2 fwPolicy2 = (INetFwPolicy2)Activator.CreateInstance(tNetFwPolicy2); | ||
INetFwRules Rules = fwPolicy2.Rules; | ||
IEnumerator rulesEnumerator = Rules.GetEnumerator(); | ||
foreach(INetFwRule rule in Rules) | ||
{ | ||
String exePath = rule.ApplicationName as string; | ||
if (exePath != null && exePath.Length > 0) | ||
{ | ||
if (rule.Action == 0) | ||
{ | ||
if (!File.Exists(exePath)) | ||
{ | ||
if (Regex.IsMatch(exePath, pattern)) | ||
{ | ||
counter += 1; | ||
Console.WriteLine(exePath); | ||
fwPolicy2.Rules.Remove(rule.Name); | ||
} | ||
} | ||
} | ||
} | ||
} | ||
Console.WriteLine("-"); | ||
Console.WriteLine(counter + " rules deleted."); | ||
Console.WriteLine("Press any key to exit..."); | ||
Console.ReadKey(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,6 +10,7 @@ class Program | |
{ | ||
static void Main(string[] args) | ||
{ | ||
FWIfz fwi = new FWIfz(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<assembly manifestVersion="1.0" xmlns="urn:schemas-microsoft-com:asm.v1"> | ||
<assemblyIdentity version="1.0.0.0" name="MyApplication.app"/> | ||
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v2"> | ||
<security> | ||
<requestedPrivileges xmlns="urn:schemas-microsoft-com:asm.v3"> | ||
<!-- Opciones del manifiesto UAC | ||
Si quiere cambiar el nivel del Control de cuentas de usuario de Windows reemplace el | ||
nodo requestedExecutionLevel por uno de los siguientes. | ||
<requestedExecutionLevel level="asInvoker" uiAccess="false" /> | ||
<requestedExecutionLevel level="requireAdministrator" uiAccess="false" /> | ||
<requestedExecutionLevel level="highestAvailable" uiAccess="false" /> | ||
Especificar el elemento requestedExecutionLevel deshabilitará la virtualización de archivos y registros. | ||
Quite este elemento si la aplicación necesita esta virtualización para la compatibilidad | ||
con versiones anteriores. | ||
--> | ||
<requestedExecutionLevel level="requireAdministrator" uiAccess="false" /> | ||
</requestedPrivileges> | ||
</security> | ||
</trustInfo> | ||
|
||
<compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1"> | ||
<application> | ||
<!-- Una lista de las versiones de Windows en la que se ha probado esta aplicación y | ||
con la que se ha diseñado para que trabaje. Quite la marca de comentario de los elementos adecuados y Windows seleccionará | ||
automáticamente el entorno más compatible. --> | ||
|
||
<!-- Windows Vista --> | ||
<!--<supportedOS Id="{e2011457-1546-43c5-a5fe-008deee3d3f0}" />--> | ||
|
||
<!-- Windows 7 --> | ||
<!--<supportedOS Id="{35138b9a-5d96-4fbd-8e2d-a2440225f93a}" />--> | ||
|
||
<!-- Windows 8 --> | ||
<!--<supportedOS Id="{4a2f28e3-53b9-4441-ba9c-d69d4a4a6e38}" />--> | ||
|
||
<!-- Windows 8.1 --> | ||
<!--<supportedOS Id="{1f676c76-80e1-4239-95bb-83d0f6d0da78}" />--> | ||
|
||
<!-- Windows 10 --> | ||
<!--<supportedOS Id="{8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a}" />--> | ||
|
||
</application> | ||
</compatibility> | ||
|
||
<!-- Indica que la aplicación tiene reconocimiento de PPP y Windows no la escalará de forma automática a | ||
PPP superiores. Las aplicaciones de Windows Presentation Foundation (WPF) tienen reconocimiento de PPP automático y no necesitan | ||
participar. Las aplicaciones de Windows Forms que apuntan a .NET Framework 4.6 que participan en esta configuración, también | ||
deben establecer la configuración 'EnableWindowsFormsHighDpiAutoResizing' en 'true' en app.config. --> | ||
<!-- | ||
<application xmlns="urn:schemas-microsoft-com:asm.v3"> | ||
<windowsSettings> | ||
<dpiAware xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">true</dpiAware> | ||
</windowsSettings> | ||
</application> | ||
--> | ||
|
||
<!-- Habilitar los temas para los controles y cuadros de diálogo comunes de Windows (Windows XP y versiones posteriores) --> | ||
<!-- | ||
<dependency> | ||
<dependentAssembly> | ||
<assemblyIdentity | ||
type="win32" | ||
name="Microsoft.Windows.Common-Controls" | ||
version="6.0.0.0" | ||
processorArchitecture="*" | ||
publicKeyToken="6595b64144ccf1df" | ||
language="*" | ||
/> | ||
</dependentAssembly> | ||
</dependency> | ||
--> | ||
|
||
</assembly> |
Oops, something went wrong.