当前位置 : 主页 > 编程语言 > python >

Python实现一键打开/关闭防火墙

来源:互联网 收集:自由互联 发布时间:2022-07-19
利用python一键打开或关闭防火墙 #!/usr/bin/python # -*- coding: GBK -*- """ @author: Roc-xb """ import os # 启用防火墙 def open_firewall (): os . system ( "netsh advfirewall set currentprofile state on" ) os . system ( "nets


利用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("防火墙已关闭")
上一篇:python datetime和字符串如何相互转化?
下一篇:没有了
网友评论