Loading

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("防火墙已关闭")

posted @ 2021-11-15 00:28  Roc-xb  阅读(95)  评论(0)    收藏  举报

易微帮源码


易微帮官网