Python实现一键打开/关闭防火墙
利用python一键打开或关闭防火墙
#!/usr/bin/python
# -*- coding: GBK -*-
"""
@author: Roc-xb
"""
import os
# 启用防火墙
def open_firewall():
os.system("netsh advfirewall set currentprofile state on")
os.system("netsh advfirewall set domainprofile state on")
os.system("netsh advfirewall set privateprofile state on")
print("防火墙已开启")
# 关闭防火墙
def close_firewall():
os.system("netsh advfirewall set currentprofile state off")
os.system("netsh advfirewall set domainprofile state off")
os.system("netsh advfirewall set privateprofile state off")
print("防火墙已关闭")

浙公网安备 33010602011771号