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.

  • If it's anti-procrastination you're concerned with, then can I suggest physically unplugging the network cable and/or switching off the WIFI adapter. This works especially well if you have to get up from your chair to plug it back in.... – DAB Oct 17 '17 at 8:17

You can also, disable the internet connection just by releasing the assigned IP address.

From the elevated command prompt (Run as administrator), type:


When you want to enable the internet connection then:


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. – AlainD Jul 6 '17 at 21:23
route delete -p


route add -p MASK <gataway ISP1> METRIC <METRIC 1> IF <interface number ISP1>
route add -p MASK <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
    Huh? a WAN is the external connections. – DavidPostill Jan 2 '17 at 17:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.