I have an advanced rule setup in Windows firewall that I want to be able to turn on and off via an AutoHotkey script.
RunWaitOne(command) {
shell := ComObjCreate("WScript.Shell")
exec := shell.Exec(ComSpec " /C " command)
return exec.StdOut.ReadAll()
}
!d::
if WinActive("ahk_exe Hearthstone.exe")
RunWaitOne("netsh advfirewall set rule name=hearthstone new enable=yes")
Sleep, 1000 ; 1000ms of delay between disconnecting and reconnecting
RunWaitOne("netsh advfirewall set rule name=hearthstone new enable=no")
return
The rule works fine manually when I turn it on and off via the pannel however when testing the script and the action manually I get an error: The following command was not found: advfirewall set rule name=hearthstone new enable=yes.
This question suggested it was a missing helper however when I ran netsh show helper
the .DLL for advfirewall is present so I'm rather at a loss on how to further debug this.
EDIT: Yes I have AHK running with elevated privileges.