AHK stopped working - under same conditions

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
xmahk
Posts: 5
Joined: 07 Oct 2022, 07:30

AHK stopped working - under same conditions

Post by xmahk » 07 Oct 2022, 07:38

I have been using AHK for about a month and the trivial script below to disconnect (Ctrl-F5) and reconnect (Ctrl-F6) from the internet. Never had a problem and it worked whether I was using a VPN or not. Nothing has changed in my setup.

Suddenly a few days ago it stopped working. The network interface is still "Ethernet" and I see the commands being executed in the AHK logs, but the it no longer has any effect - the internet connection stays up.

Any hints on how to fix the issue?

Code: Select all

^f5::
run, *runas %comspec% /c netsh interface set interface name="Ethernet" admin=disabled,,hide
return	

^f6::
run, *runas %comspec% /c netsh interface set interface name="Ethernet" admin=enabled,,hide
return

safetycar
Posts: 435
Joined: 12 Aug 2017, 04:27

Re: AHK stopped working - under same conditions

Post by safetycar » 07 Oct 2022, 08:56

Test that both command lines are working from the console window first, it might give you hints.

xmahk
Posts: 5
Joined: 07 Oct 2022, 07:30

Re: AHK stopped working - under same conditions

Post by xmahk » 07 Oct 2022, 09:02

safetycar wrote:
07 Oct 2022, 08:56
Test that both command lines are working from the console window first, it might give you hints.
Pardon my ignorance, how do I manually launch the console window?
I have been launching by double-clicking the .ahk script, and when I tried to launch by hitting AutoHotkey.exe it brought up the help and instructions to make a script file first, with no hints on how to run the console by itself in ad-hoc mode.

safetycar
Posts: 435
Joined: 12 Aug 2017, 04:27

Re: AHK stopped working - under same conditions

Post by safetycar » 07 Oct 2022, 09:53

I meant launching cmd.exe from windows. If you open the start menu and start typing "cmd.exe" you should see the program, you can right click it and open as administrator, (a permission that you were already trying to use with "runas*").
And there introducing the middle part that was intended to be run there: netsh interface set interface name="Ethernet" admin=disabled
And the other similar one with the "enabled" flag

xmahk
Posts: 5
Joined: 07 Oct 2022, 07:30

Re: AHK stopped working - under same conditions

Post by xmahk » 07 Oct 2022, 12:50

safetycar wrote:
07 Oct 2022, 09:53
I meant launching cmd.exe from windows. If you open the start menu and start typing "cmd.exe" you should see the program, you can right click it and open as administrator, (a permission that you were already trying to use with "runas*").
And there introducing the middle part that was intended to be run there: netsh interface set interface name="Ethernet" admin=disabled
And the other similar one with the "enabled" flag
Thanks, indeed the issue seems to be with netsh. Looks like a windows update broke the command.

- netsh interface show
--- lists the interfaces and validates that my interface is indeed Ethernet

- netsh interface set interface name="Ethernet" admin=disabled,,hide
--- says: disabled,,hide is not an acceptable value for admin.

- netsh interface set interface name="Ethernet" admin=disabled
--- says: The system cannot find the file specified.

Since I am running this in an Administrator: Command Prompt, and it "used to" run fine, the only explanation that I can come up with is that netsh syntax has changed making the script no longer valid.

safetycar
Posts: 435
Joined: 12 Aug 2017, 04:27

Re: AHK stopped working - under same conditions

Post by safetycar » 07 Oct 2022, 23:38

The ending with ,,hide is part of ahk's "run" parameters, it is expected to not work.
About the rest, I don't know enough about netsh to give you better tips.
I can see some help documentation introducing netsh interface set interface
I see another parameter, "connect=" admitting values "connected" and "disconnected". And there are some remarks about it at the bottom.
But since I cannot reproduce your issue I can't help much, maybe you can find better tips through web search?

xmahk
Posts: 5
Joined: 07 Oct 2022, 07:30

Re: AHK stopped working - under same conditions

Post by xmahk » 08 Oct 2022, 02:55

safetycar wrote:
07 Oct 2022, 23:38
The ending with ,,hide is part of ahk's "run" parameters, it is expected to not work.
About the rest, I don't know enough about netsh to give you better tips.
I can see some help documentation introducing netsh interface set interface
I see another parameter, "connect=" admitting values "connected" and "disconnected". And there are some remarks about it at the bottom.
But since I cannot reproduce your issue I can't help much, maybe you can find better tips through web search?
Don't worry about it. I did a lot of searching and found two sets of syntax (it apparently changed in the past already) and my syntax is the most recent. Clearly it must have changed again and documentation has not caught up yet. I posted on Microsoft's support site and I am waiting for a reply.

Since my particular scripts are an extremely common use of AHK, I will make sure to post the solution here once I receive it.

xmahk
Posts: 5
Joined: 07 Oct 2022, 07:30

Re: AHK stopped working - under same conditions

Post by xmahk » 17 Oct 2022, 10:42

UPDATE:

After a lot of research it is pretty obvious that Windows commands for network enabling/disabling are quite broken now. (1) netsh no longer works, at least in windows 10. (2) There is a command for PowerShell, but it is very slow (3-5 seconds) and is not adequate for a lot of purposes.

The only thing that seems to function fast enough is the ControlPanel NetworkConnections "Disable this network device" menu option.
That tells me that there *must* be a command that could be used in an AHK script, but it appears that at this time it is not documented.

I hope this is useful even though it is not ideal. I know that a LOT of people rely on AHK to disable/enable the network interface and must be frustrated at this moment.

Post Reply

Return to “Ask for Help (v1)”