How can I disable internet access on Windows 7 via the command line?

5

3

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.

William Saunders

Posted 2014-11-29T18:57:53.707

Reputation: 542

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 – 2017-10-17T08:17:27.713

Answers

3

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

vembutech

Posted 2014-11-29T18:57:53.707

Reputation: 5 693

3

Try netsh:

netsh interface set interface "Local Area Connection " ENABLE
netsh interface set interface "Local Area Connection " DISABLE

tlng05

Posted 2014-11-29T18:57:53.707

Reputation: 699

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 – 2017-07-06T21:23:09.180

0

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.

sunwu kong

Posted 2014-11-29T18:57:53.707

Reputation: 1

1Huh? a WAN is the external connections. – DavidPostill – 2017-01-02T17:19:55.633

0

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>

STTR

Posted 2014-11-29T18:57:53.707

Reputation: 6 180