#关闭端口
netsh advfirewall firewall add rule name=禁用TCP端口 dir=in action=block protocol=TCP localport="8080"
#开启端口
netsh advfirewall firewall add rule name=启用用TCP端口 dir=in action=allow protocol=TCP localport="8080"
#删除规则
netsh advfirewall firewall delete rule name=禁用TCP端口
参考:
https://blog.51fuli.info/windows%e9%98%b2%e7%81%ab%e5%a2%99-netsh-advfirewall-%e8%ae%be%e7%bd%ae/