I am going to tell you how to get windows firewall status programmatically alongwith the example source code. To achieve this the netsh command is executed and its output is captured. For this the process ExecuteProcessSilentlyAndCaptureOutput is used
To see the code for the ExecuteProcessSilentlyAndCaptureOutput first read the following article
Get this code running in your program.Now we are going to use this process to execute netsh , netsh will get the firewall status in the variable em>strOut
ExecuteProcessSilentlyAndGetOutput("cmd.exe", "/c netsh advfirewall show publicprofile state", strOut) Dim strResultPublicProfile = strOut If strResultPublicProfile.Contains("ON") Then strOut2 = "Windows Firewall for public profile : " & "ON" appendOutput(strOut2, False) 'appendoutput function outputs to a rich text box
That is all.
If you liked this article please do leave a reply and share it with friends.
Thanks.