Jun
20
2022
利用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("防火墙已关闭")
微信扫一扫,打赏作者吧~
最活跃的读者