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

打赏

本文固定链接: https://www.cxy163.net/archives/1935 | 绝缘体-小明哥的技术博客

该日志由 绝缘体.. 于 2022年06月20日 发表在 python, 编程语言, 首页 分类下,
原创文章转载请注明: 利用python一键打开或关闭防火墙 | 绝缘体-小明哥的技术博客
关键字: , , , ,

报歉!评论已关闭.