Posts: 1,271
Threads: 399
Joined: Mar 2003
Allow, Block Or Remove Apps From Windows Firewall Using Context Menu
http://www.addictivetips.com/windows-ti ... text-menu/
do you have an idea how to do that with qm?
Posts: 12,086
Threads: 142
Joined: Dec 2002
http://stackoverflow.com/questions/1137 ... ewall?rq=1
Macro
Firewall add authorized application
str appName= "Atest"
str appPath.expandpath ( "$my qm$\Atest.exe" )
typelib NetFwTypeLib {58FBCF7C-E7A9-467C-80B3-FC65E8FCCA08} 1.0
NetFwTypeLib. INetFwMgr manager._create ( "{304CE942-6E39-40D8-943A-B913C40C9CD4}" )
NetFwTypeLib. INetFwAuthorizedApplications apps= manager.LocalPolicy .CurrentProfile .AuthorizedApplications
NetFwTypeLib. INetFwAuthorizedApplication a
int i= list ( "Allow[]Block[]Find[]Remove" appPath "Firewall" )
sel i
, case [1 , 2 ] ;;add
, a._create ( "HNetCfg.FwAuthorizedApplication" )
, a.Name = appName
, a.ProcessImageFileName = appPath
, a.Enabled = iif ( i= 1 TRUE 0 )
, apps.Add ( a)
,
, case 3 ;;find
, int isInList
, foreach ( a apps) if ( appPath~ _s.from ( a.ProcessImageFileName )) isInList= 1 ; break
, mes F "{ iif ( isInList `found` `not found` ) }[]{ appPath}"
,
, case 4 ;;remove
, apps.Remove ( appPath)
Posts: 1,271
Threads: 399
Joined: Mar 2003
very cool!
so instead of installing a 3rd party software which also clutter my already huge context menu on exe, i add the firewall entry to my Options sub menu.
again: thank you for your fast support.
Posts: 1,271
Threads: 399
Joined: Mar 2003
Function
Firewall
Trigger
$sm "Options\Firewall" 0x0 "exe" "" "Allow, Block Or Remove Apps From Windows Firewall"
function $ files
str f
foreach f files
, str appName = f.getfilename
, str appPath.expandpath ( f)
,
, typelib NetFwTypeLib {58FBCF7C-E7A9-467C-80B3-FC65E8FCCA08} 1.0
,
, NetFwTypeLib. INetFwMgr manager._create ( "{304CE942-6E39-40D8-943A-B913C40C9CD4}" )
, NetFwTypeLib. INetFwAuthorizedApplications apps= manager.LocalPolicy .CurrentProfile .AuthorizedApplications
, NetFwTypeLib. INetFwAuthorizedApplication a
,
, int i= list ( "Allow[]Block[]Find[]Remove" appPath "Firewall" )
, sel i
,, case [1 , 2 ] ;;add
,, a._create ( "HNetCfg.FwAuthorizedApplication" )
,, a.Name = appName
,, a.ProcessImageFileName = appPath
,, a.Enabled = iif ( i= 1 TRUE 0 )
,, apps.Add ( a)
,,
,, case 3 ;;find
,, int isInList
,, foreach ( a apps) if ( appPath~ _s.from ( a.ProcessImageFileName )) isInList= 1 ; break
,, mes F "{ iif ( isInList `found` `not found` ) }[]{ appPath}"
,,
,, case 4 ;;remove
,, apps.Remove ( appPath)
Posts: 12,086
Threads: 142
Joined: Dec 2002
Posts: 1,271
Threads: 399
Joined: Mar 2003
Gintaras Wrote: ,str appPath=fedited.
the Firewall entry is last in order in my context menu, how to i move it up?
Posts: 12,086
Threads: 142
Joined: Dec 2002
Don't remember, probably menu items are ordered like QM items in the main list when QM started.
Posts: 1,271
Threads: 399
Joined: Mar 2003
they seem to be sorted by Date modified:
Firewall 11.12.2013 22:20
Autostart 22.06.2007 23:56
Attached Files
Image(s)
Posts: 12,086
Threads: 142
Joined: Dec 2002
Restart QM or reload file.
Posts: 1,271
Threads: 399
Joined: Mar 2003
can you add a weight parameter to context, so that i have to rely on my own sorting?
Posts: 12,086
Threads: 142
Joined: Dec 2002
Move all context menu macros to a single folder in QM, order as you like, and restart QM. It will be easier and more clear than adding more parameters.
Posts: 726
Threads: 99
Joined: Mar 2018
11-17-2018, 08:10 PM
(This post was last modified: 11-17-2018, 08:13 PM by win .)
I often use the software Firewall App Blocker to add firewall rules. Today I found the above code. After testing, I found that it could not take effect.
system: windows 7 , 64bit
https://www.sordum.org/8125/firewall-app...-fab-v1-6/
Posts: 726
Threads: 99
Joined: Mar 2018
I opened the firewall and checked the settings of the rules. I found that the above code failed. The settings of Firewall App Blocker are successful. I hope someone can help me test it. Thanks.
Posts: 1,337
Threads: 61
Joined: Jul 2006
11-18-2018, 10:59 PM
(This post was last modified: 11-18-2018, 11:03 PM by Kevin .)
looking at your attachment it seems your add/block code is not successful. Why i cannot say. Don't have that program.
post your qm code here please
Posts: 726
Threads: 99
Joined: Mar 2018
11-18-2018, 11:14 PM
(This post was last modified: 11-18-2018, 11:16 PM by win .)
The code is here, after I use this code, I have not found the set program in the firewall rules.
http://www.quickmacros.com/forum/showthr...0#pid24040
firewall-app-blocker down link:
https://www.sordum.org/downloads/?firewall-app-blocker
Posts: 1,337
Threads: 61
Joined: Jul 2006
the code works for me if i add it shows says found if i remove it says not found. Don't need the other program but if you use latest version 1.6 it will show the added rule in that program
Posts: 726
Threads: 99
Joined: Mar 2018
11-18-2018, 11:48 PM
(This post was last modified: 11-19-2018, 12:02 AM by win .)
After the code runs, select Block, run the code again, select Find, although it can be found,
but there are no rules added in the system firewall, and I can't see the added items using the latest Firewall App Blocker (Fab) v1.6.
I don't use code, directly added any program using Firewall App Blocker (Fab) v1.6, which I can see in the firewall rules.
system: win7 x64