Can't enable or disable a firewall rule Topic is solved

Ask gaming related questions (AHK v1.1 and older)
Yaggabagga
Posts: 4
Joined: 15 May 2019, 21:49

Can't enable or disable a firewall rule

20 May 2019, 07:41

Hello!

I am trying to block the internet connection to a game (or all games) via a looping script. I want to block the internet connection, wait 1 second, and reenable the connection.

This is what I have so far:

Code: Select all

if not A_IsAdmin
{
   Run *RunAs "%A_ScriptFullPath%"
   ExitApp
}

Insert::Suspend

Loop {

Run, netsh advfirewall firewall set rule name="DeerHunter2012" new enable=yes,, hide ; Disables the internet connection
Sleep, 1000
Run, netsh advfirewall firewall set rule name="DeerHunter2012" new enable=no,, hide ; Enables the internet connection

}
It simply doesn't work. My internet stays on and I can't see the rule being toggled on an off in the firewall GUI. Any ideas?
gregster
Posts: 9056
Joined: 30 Sep 2013, 06:48

Re: Can't enable or disable a firewall rule  Topic is solved

20 May 2019, 14:30

All code below the hotkey definition Insert::Suspend is currently unreachable. Compare https://www.autohotkey.com/docs/Scripts.htm#auto :
After the script has been loaded, it begins executing at the top line, continuing until a Return, Exit, hotkey/hotstring label, or the physical end of the script is encountered (whichever comes first).
Yaggabagga
Posts: 4
Joined: 15 May 2019, 21:49

Re: Can't enable or disable a firewall rule

20 May 2019, 18:40

Got it to work by moving

Code: Select all

Insert::Suspend
to after the loop.

Thank you!
Crosshair
Posts: 2
Joined: 15 Dec 2019, 03:13

Firewall by key

15 Dec 2019, 03:56

I need autohotkey change Windows Firewall

XButton1 Down [All inbound Rules Block]
XButton1 UP [All inbound Rules Unblock]
and
XButton2 Down [All Outbound Rules Block]
XButton2 UP [All Outbound Rules Unblock]
and
MButton Down [All Network Block]
MButton UP [All Network Unblock]
-------------------------------------------------------
and small voice at the finish every script

Return to “Gaming Help (v1)”

Who is online

Users browsing this forum: bowie1123 and 71 guests