2013. 11. 22.

How to Configure firewalls by command line in windows

When your application use network,  user will meet the 'Firewall warning messages' . If user ignores it, your application cannot work properly.   Even if your program is used by many people and  it is distirbuted automatically.  You must make firewall allows your application.

This batch file is about configure firewall.


1) XP Case 

firewall.bat  file

rem delete previous configuration to prevent duplicate2)
netsh firewall delete allowedprogram c:\myapp\myapp.exe
rem add myapp.exe to allow list.
netsh firewall add allowedprogram c:\myapp\myapp.exe Myapp-firewall enable



2) Windows 7 Case


REM *** Delete previous firewall config. ***
netsh advfirewall firewall delete rule name=MyAppfirewall

REM *** allow inbound ***
netsh advfirewall firewall add rule name="MyAppfirewall" dir=in protocol=tcp action=allow program="c:\MyApp\MyApp.exe"
netsh advfirewall firewall add rule name="MyAppfirewall" dir=in protocol=udp action=allow program="c:\MyApp\MyApp.exe"

REM  *** allow inbound  ***
netsh advfirewall firewall add rule name="MyAppfirewall" dir=out protocol=tcp action=allow program="c:\MyApp\MyApp.exe"
netsh advfirewall firewall add rule name="MyAppfirewall" dir=out protocol=udp action=allow program="c:\MyApp\MyApp.exe"

댓글 없음:

댓글 쓰기