代码改变世界

命令行下开启与关闭windows防火墙关端口(转)

2013-11-07 10:34  狼人:-)  阅读(1693)  评论(0编辑  收藏  举报

sc config sharedaccess start= auto //设置防火墙服务为自动

net start sharedaccess //开启防火墙服务

 

关闭端口

netsh firewall add portopening protocol = TCP port = 139 name = "关闭139" mode = DISABLE

netsh firewall add portopening protocol = TCP port = 445 name = "关闭445" mode = DISABLE

netsh firewall add portopening protocol = UDP port = 137 name = "关闭137" mode = DISABLE

netsh firewall add portopening protocol = UDP port = 138 name = "关闭138" mode = DISABLE 

 

开启端口

netsh firewall add portopening protocol = TCP port = 139 name = "开启139" mode = ENABLE

netsh firewall add portopening protocol = TCP port = 445 name = "开启445" mode =  ENABLE

netsh firewall add portopening protocol = UDP port = 137 name = "开启137" mode =  ENABLE

netsh firewall add portopening protocol = UDP port = 138 name = "开启138" mode =  ENABLE