Windows Server2008通过命令行方式添加防火墙规则

Windows Server2008增加了一个名叫netsh的命令行工具,通过它可以用批处理方式添加防火墙出入栈规则:

入栈规则:

set PORT=3389
set RULE_NAME="_远程连接端口:%PORT% 入栈规则"
netsh advfirewall firewall show rule name=%RULE_NAME% >nul
if not ERRORLEVEL 1 (
    rem 对不起,规则 %RULENAME% 已经存在
) else (
    echo 规则 %RULENAME% 创建中...
    netsh advfirewall firewall add rule name=%RULE_NAME% dir=in action=allow protocol=TCP localport=%PORT%

出栈规则:

set PORT=3389
set RULE_NAME="_远程连接端口:%PORT% 出栈规则"
netsh advfirewall firewall show rule name=%RULE_NAME% >nul
if not ERRORLEVEL 1 (
    rem 对不起,规则 %RULENAME% 已经存在
) else (
    echo 规则 %RULENAME% 创建中...
    netsh advfirewall firewall add rule name=%RULE_NAME% dir=outaction=allow protocol=TCP localport=%PORT%


参考:http://*.com/questions/15171255/how-to-open-ports-on-windows-firewall-through-batch-file

上一篇:Mol Cell Proteomics. | Prediction of LC-MS/MS properties of peptides from sequence by deep learning (通过深度学习技术根据肽段序列预测其LC-MS/MS谱特征) (解读人:梅占龙)


下一篇:(转) Awesome - Most Cited Deep Learning Papers