How can I easily disable (and later re-enable) internet access on Windows 7 via the command line (for an anti-procrastination script)? It would work fine if rebooting re-enables internet access. No local network access is required.
4 Answers
You can also, disable the internet connection just by releasing the assigned IP address.
From the elevated command prompt (Run as administrator), type:
ipconfig/release
When you want to enable the internet connection then:
ipconfig/renew
Hope this helps
Try netsh:
netsh interface set interface "Local Area Connection " ENABLE
netsh interface set interface "Local Area Connection " DISABLE
-
This did not work for me on Windows 8.1, though
ipconfig \release
did. Tried different combinations of the name,Run as Administrator
, and so on. Nothing appeared to work. Recommend answer from @vernbutech.– AlainDJul 6, 2017 at 21:23
route delete -p 0.0.0.0
{shutdown}
route add -p 0.0.0.0 MASK 0.0.0.0 <gataway ISP1> METRIC <METRIC 1> IF <interface number ISP1>
route add -p 0.0.0.0 MASK 0.0.0.0 <gataway ISP2> METRIC <METRIC 2> IF <interface number ISP2>
For me (win 7) these commands only work if I deleted the space before the second ".
netsh interface set interface "Local Area Connection" ENABLE
netsh interface set interface "Local Area Connection" DISABLE
I'm wondering if there is a command that can cut off all external connections but leave the wan and lan OK.
-
1