Register a program (windows7 and XP) in the firewall exceptions)

Source: Internet
Author: User

P2P transmission of products has always been a tangle of problems, and sometimes there is a situation in the LAN that cannot be directly connected, to go through forwarding. During the test, it was found that the reason was Windows Firewall, And the P2P firewall cannot be directly connected.

My own system is win7. When the software runs for the first time, the system will prompt whether to add the program to the firewall exception program. I accidentally closed the window and caused the problem.

I found some information on the Internet. I wanted to write the Registry when I started the software. I wrote the corresponding registry under win7, but the Windows Firewall exception program list never showed the corresponding items, it is quite tangled (people who know it may have trouble to tell). Considering that the registry write in the program will be intercepted by 360, we decided to implement this function in the packaging and installation script.

 

NSIs script execution statement

Section     ${If} ${AtLeastWinVista}   nsExec::ExecToLog 'cmd.exe /c "netsh advfirewall firewall delete rule name =\"xxxxxx\" program=\"$INSTDIR\xxx.exe\""'nsExec::ExecToLog 'cmd.exe /c "netsh advfirewall firewall add rule name =\"xxxxxx\" dir=in program=\"$INSTDIR\xxx.exe\" action=allow Protocol=udp Profile=Public"'nsExec::ExecToLog 'cmd.exe /c "netsh advfirewall firewall add rule name =\"xxxxxx\" dir=in program=\"$INSTDIR\xxx.exe\" action=allow Protocol=tcp Profile=Public"'  ${Else}nsExec::ExecToLog 'cmd.exe /c "netsh firewall delete allowedprogram program = \"$INSTDIR\xxx.exe\""'nsExec::ExecToLog 'cmd.exe /c "netsh firewall add allowedprogram program = \"$INSTDIR\xxx.exe\" name=\"xxxxxx\" ENABLE"'${EndIf}   SectionEnd

 

Register a program in the firewall exceptions

Http://blog.csdn.net/blpluto/article/details/5979684

 

Netsh advfirewall firewall commands

Windows 7 http://technet.microsoft.com/zh-cn/library/dd734783 (V = ws.10)

XP

Http://technet.microsoft.com/zh-cn/library/cc771046 (V = ws.10). aspx

 

NSIs basic syntax

Http://www.cppblog.com/Mumoo/archive/2012/05/11/174542.aspx

Macro file of the logical statement :! Include logiclib. nsh
If statement:
$ {If} $0 = 'some value'
MessageBox mb_ OK '$0 is some value'
$ {Elseif} $0 = 'some other value'
MessageBox mb_ OK '$0 is some other value'
$ {Else}
MessageBox mb_ OK '$0 is "$0 "'
$ {Endif}

While loop:

Strcpy $ R1 0 ---------- the string value is an integer.
$ {While} $ R1 <5
Intop $ R1 $ R1 + 1
Detailprint $ R1 ---------- print string
$ {Endwhile}

 

NSIs obtains the current system version

Http://www.flighty.cn/html/bushu/20110322_114.html

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.