CMD添加exe到防火墙白名单示例
@echo off
cd "%CD%"
SET RuleName="ExeName"
SET ExeName="ExeName.exe"
for /f "tokens=4,5 delims=. " %%a in ('ver') do if %%a%%b geq 60 goto new
:old
cmd /c netsh firewall delete allowedprogram program="%CD%\%ExeName%" profile=ALL
cmd /c netsh firewall add allowedprogram program="%CD%\%ExeName%" name="%RuleName%" ENABLE
cmd /c netsh firewall add allowedprogram program="%CD%\%ExeName%" name="%RuleName%" ENABLE profile=ALL
goto end
:new
cmd /c netsh advfirewall firewall delete rule name="%RuleName%"
cmd /c netsh advfirewall firewall add rule name="%RuleName%" dir=in action=allow program="%CD%\%ExeName%" protocol=tcp enable=yes profile=public
cmd /c netsh advfirewall firewall add rule name="%RuleName%" dir=in action=allow program="%CD%\%ExeName%" protocol=udp enable=yes profile=public
cmd /c netsh advfirewall firewall add rule name="%RuleName%" dir=in action=allow program="%CD%\%ExeName%" protocol=tcp enable=yes profile=domain
cmd /c netsh advfirewall firewall add rule name="%RuleName%" dir=in action=allow program="%CD%\%ExeName%" protocol=udp enable=yes profile=domain
cmd /c netsh advfirewall firewall add rule name="%RuleName%" dir=in action=allow program="%CD%\%ExeName%" protocol=tcp enable=yes profile=private
cmd /c netsh advfirewall firewall add rule name="%RuleName%" dir=in action=allow program="%CD%\%ExeName%" protocol=udp enable=yes profile=private
:end

浙公网安备 33010602011771号