If the caller want this kind of messages, it should be responsible for printing them, not this function. Here, locate and click on Windows Defender Firewall. You can open the Control panel from the Run (Win + R) dialog box as well. To turn off the Windows Firewall in Windows 10, follow these steps: Open Control Panel from the desktop icon if you have one. Subprocess.call("netsh advfirewall firewall set rule name="+ rule_name +" new enable=no", shell=True, stdout=DEVNULL, stderr=DEVNULL)ĭon't use string concatenation, but use f"',Īlso note that I removed the print call from the function as it impairs reusability. You can turn off Windows Firewall to remove these conflicts and solve the Avast firewall issue. Subprocess.call("netsh advfirewall firewall set rule name="+ rule_name +" new enable=yes", shell=True, stdout=DEVNULL, stderr=DEVNULL) """ Enable/Disable specific rule, 0 = Disable / 1 = Enable """ Print("Rule", rule_name, "for", file_path, "added") Subprocess.call("netsh advfirewall firewall add rule name="+ rule_name +" dir=out action=block enable=no program=" + file_path, shell=True, stdout=DEVNULL, stderr=DEVNULL) Maybe we will even implement whitelist import/export before the whole sync feature. IsAdmin = ()Ĭ(None, "runas", sys.executable, _file_, None, 1) """ Force to start application with admin rights """ I'm wondering if there is any better method to do this? Executing the cmd command inside Python seems to be impractical to me. I currently use subprocess.call to execute the netsh command inside Python. I have this following module using for adding and enabling/disabling Windows Firewall rules using Python.
0 Comments
Leave a Reply. |