nsisFirewall是NSIS添加应用程序到防火墙允许规则的插件

/*
nsisFirewall是NSIS添加应用程序到防火墙允许规则的插件
nsisFirewall允许你执行两个任务:
添加一个应用程序到系统防火墙允许规则列表.
从系统防火墙允许规则列表中移除相应的应用程序.
使用nsisFirewall最好使用RequestExecutionLevel来提高用户权限.
通常情况下你不需要检查它的返回值
运行"firewall.cpl"显示防火墙控制面板.
*/
!ifdef TARGETDIR
!addplugindir "${TARGETDIR}"
!else
!addplugindir "..bin"
!endif
RequestExecutionLevel admin
Name "Sample nsisFirewall"
OutFile "Sample.exe"
ShowInstDetails show
Section "Main program"
; Add NOTEPAD to the authorized list
nsisFirewall::AddAuthorizedApplication "$WINDIRNotepad.exe" "nsisFirewall Test"
Pop $0
IntCmp $0 0 +3
MessageBox MB_OK "A problem happened while adding program to Firewall exception list (result=$0)"
Return
Exec "rundll32.exe shell32.dll,Control_RunDLL firewall.cpl"
MessageBox MB_OK "Program added to Firewall exception list.$r$n(close the control panel before clicking OK)"
; Remove NOTEPAD from the authorized list
nsisFirewall::RemoveAuthorizedApplication "$WINDIRNotepad.exe"
Pop $0
IntCmp $0 0 +3
MessageBox MB_OK "A problem happened while removing program to Firewall exception list (result=$0)"
Return
Exec "rundll32.exe shell32.dll,Control_RunDLL firewall.cpl"
MessageBox MB_OK "Program removed to Firewall exception list"
SectionEnd
© 版权声明
THE END
喜欢就支持一下吧
点赞5 分享
评论 抢沙发

请登录后发表评论

    暂无评论内容