Python 获取防火墙策略并保存为TXT文档
作者:互联网
from winreg import EnumValue, CloseKey, OpenKey,HKEY_LOCAL_MACHINE
def firewallRules():
key = OpenKey(HKEY_LOCAL_MACHINE,\
r"SYSTEM\CurrentControlSet\Services\SharedAccess\Parameters\FirewallPolicy\FirewallRules")
i = 0
with open('firewallRules.txt', mode='at', encoding='utf-8') as f:
while True:
try:
name,value, t = EnumValue(key,i)
f.write(name+' '+value+'\n')
i=i+1
except WindowsError:
break
CloseKey(HKEY_LOCAL_MACHINE)
return None
firewallRules()
标签:firewallRules,Python,HKEY,防火墙,MACHINE,CloseKey,OpenKey,TXT,LOCAL 来源: https://blog.csdn.net/m0_53164169/article/details/122578831