TC buttons to turn Firewall on/off

English support forum

Moderators: Hacker, petermad, Stefan2, white

Post Reply
kodepr
Junior Member
Junior Member
Posts: 45
Joined: 2019-09-05, 08:13 UTC

TC buttons to turn Firewall on/off

Post by *kodepr »

Hi,

For testing purposes I regularly have to turn Firewall off temorarily and turn it back on afterwards.
To speed this up, is it posiible to create a button in TC for each action: "Firewall on"-button & "Firewall off"-button?
I guess this is possible with a custom command, but I have no clue of the code that should be written in the command ...

Can anyone help, please?
In case Windows-version is important: I'm running Windows 11
Using Total Commander Portable 10.00 64 bit

Thanks in advance!
User avatar
nsp
Power Member
Power Member
Posts: 1912
Joined: 2005-12-04, 08:39 UTC
Location: Lyon (FRANCE)
Contact:

Re: TC buttons to turn Firewall on/off

Post by *nsp »

If you turn on/off your firewall using a registry file you can create two button/command to turn on/off launching dedicated reg file as admin.
If you want a single on/off command you will have to write yourself a powershell or whatecer script and then launch it from TC.
kodepr
Junior Member
Junior Member
Posts: 45
Joined: 2019-09-05, 08:13 UTC

Re: TC buttons to turn Firewall on/off

Post by *kodepr »

Hi,
Thanks for the info.
I don't know how to create a registry file or how to write a powershell or whatever script.
Can anyone help me out with that?
Thanks in advance!
User avatar
Dalai
Power Member
Power Member
Posts: 9941
Joined: 2005-01-28, 22:17 UTC
Location: Meiningen (Südthüringen)

Re: TC buttons to turn Firewall on/off

Post by *Dalai »

One important thing: There's not just a simple on/off switch for "the firewall". It depends on the current network the system thinks it is in. Each network can have a separate profile for which the firewall can be enabled or disabled. This can be useful to disable the firewall when a system is on the home network but it's still enabled when in a public place/network.

Enable firewall for the current active profile:

Code: Select all

%SystemRoot%\system32\netsh.exe advfirewall set currentprofile state on
I've found this command here https://www.thewindowsclub.com/netsh-command-to-manage-windows-firewall.
To disable the firewall for the current profile, replace "on" with "off". The command must be run as administrator.

Setting a registry value probably won't work without a system reboot.
#101164 Personal licence
Ryzen 5 2600, 16 GiB RAM, ASUS Prime X370-A, Win7 x64

Plugins: Services2, Startups, CertificateInfo, SignatureInfo, LineBreakInfo - Download-Mirror
kodepr
Junior Member
Junior Member
Posts: 45
Joined: 2019-09-05, 08:13 UTC

Re: TC buttons to turn Firewall on/off

Post by *kodepr »

Hi,

Tried this, but that didn't work:

Code: Select all

TOTALCMD#BAR#DATA
*%SystemRoot%\system32\netsh.exe advfirewall set currentprofile state off

FirewallControlPanel.dll,1



-1
Also tried it without the * in front of it, and then right-clicking on the button > As Administrator, but that didn't work either.
Have tried those methods in an em_ command as well, but that also didn't work.

Am I doing something wrong? Does it work on your end?
User avatar
Dalai
Power Member
Power Member
Posts: 9941
Joined: 2005-01-28, 22:17 UTC
Location: Meiningen (Südthüringen)

Re: TC buttons to turn Firewall on/off

Post by *Dalai »

Try the command on a separate CMD first before putting it on a button to see if any error occurs and which one. I can't test the command because I have the Windows Firewall service disabled on all my VMs (and I won't test it on my production system).
#101164 Personal licence
Ryzen 5 2600, 16 GiB RAM, ASUS Prime X370-A, Win7 x64

Plugins: Services2, Startups, CertificateInfo, SignatureInfo, LineBreakInfo - Download-Mirror
User avatar
ZoSTeR
Power Member
Power Member
Posts: 1049
Joined: 2004-07-29, 11:00 UTC

Re: TC buttons to turn Firewall on/off

Post by *ZoSTeR »

 
Button Firewall off:

Code: Select all

TOTALCMD#BAR#DATA
*%SystemRoot%\system32\netsh.exe
advfirewall set currentprofile state off
%SystemRoot%\system32\imageres.dll,100
Firewall off

1
-1
Button Firewall on:

Code: Select all

TOTALCMD#BAR#DATA
*%SystemRoot%\system32\netsh.exe
advfirewall set currentprofile state on
%SystemRoot%\system32\imageres.dll,101
Firewall on

1
-1

For more control over the Windows firewall I suggest WFC.
Post Reply