PHP / Python检查防火墙是否已关闭

is it possible to write a PHP script that checks if the PC's firewall is disabled and then output yes/no into a checkbox on the webpage? (Hosting my own web server using WAMP)

Currently what i have in mind is create a .bat file that checks if firewall is turned off using:

netsh advfirewall show public

then check if the State shown on CMD is On / OFF and return results to the web-page's checkbox. Thing is i have no idea how do i go about doing the check state and return results.

Please advise. Also open to other ideas / solutions that could provide similar results.

PS: Am a beginner at PHP scripting and only started learning python today and project is due in 3 weeks. Also would be nice if you could link full code solutions if you know of any. I learn faster through referencing.

You can use this command to get only the status of the public profile :

"netsh advfirewall show public state"

This command can be used in a python script with the subprocess module :

result = subprocess.check_output(["netsh", "advfirewall", "show ", "allprofiles", "state"].decode('utf-8')

The result will be a string, using regex you will be able to get the value from it.

https://docs.python.org/3/library/re.html

Example of regex :

status = re.search('state[ ]*([A-Za-z])*', result).group(1)