Answered How to work with windows firewall in C#

Calcium2

New member
Joined
Sep 30, 2020
Messages
1
Programming Experience
1-3
Window 10 firewall manage IP addresses only.

I need it to block any outbound call with certain URL strings in either:

1) path example: /sys/loius.php

search 2) variable name or 3) variable content example: ?qweit= ... &...=paris

But how in C# programming can all internet calls be trapped and controlled?
 
Topic moved to C# until the project type is specified. Title also changed to reflect the question asked.


Welcome to the forums.
 
Hi, I would highly recommend getting started by reading the following pages for familiarity :




Basically, the way I approached this previously was to first go through group policy using a service manager, but perhaps you might be interested in getting a head start with this controller lib : Allow/Block a Program (NOTE: It's my personal opinion based on the date of the linked post, that the API used may no longer function properly or may be deprecated or even obsolete), but may still be worth trying.

Also, if you want to allow a single program, ie your own application to be allowed an exception through the windows firewall, you can also do this by using ProcessStartInfo and pass the parameters from your application for the Windows Firewall through the Arguments string of the ProcessStartInfo. Btw, if you are going to go with this method, I would highly recommend you use a service controller to initialise the process.
 
One more thing, the latter will require your application to be running with higher elevation rights (run as admin). The prior will require your service to run as a system user. If you can explain more about your program, you will get more practical answers and suggestions. Hope the above helps.
 
Back
Top Bottom