Temporarily block internet connection for a program

4

I'm developing an application which is supposed to work in 2 modes online and offline. I need a simple and fast solution to block the internet connection for this particular application. Enabling/disabling this connection should be as fast as possible (one mouse click would be perfect) to test both modes.

This program is not installed, it's recompiled and executed every few minutes.

Can you recommend something?

Andrzej Gis

Posted 2013-01-25T22:03:41.260

Reputation: 371

You could disconnect/reconnect your LAN cable.That should be faster than trying out a bunch of programs to accomplish what you're looking for... – TFM – 2013-01-25T22:10:52.290

Answers

1

You'll have to use a firewall to achieve what you want. Windows Firewall is enough, but I'd suggest using a free software like COMODO Firewall because it's easier to configure and it always worked for me.

To block a program from accessing internet, go to Firewall settings > Define a New Blocked Application > Choose a running process or browse and select your program's executable file.

enter image description here

That's it! The application is now blocked from accessing internet. Then when you want to allow access, just go to "Network Security Policy" (it's hidden beneath the dialog) and allow it. As you need to quickly switch access, keep the "Network Security Policy" dialog open to do so.

Leo

Posted 2013-01-25T22:03:41.260

Reputation: 1 265

2

You could block the program at the firewall, just put these in batch files (.bat), one to enable, one to disable.

Allow

netsh advfirewall firewall add rule name="ProgramTesting" dir=out action=allow program="C:\yourprogram.exe"

Deny

netsh advfirewall firewall add rule name="ProgramTesting" dir=out action=block program="C:\yourprogram.exe"

Bali C

Posted 2013-01-25T22:03:41.260

Reputation: 1 522

The result is "OK." but my app can still access the web :( – Andrzej Gis – 2013-01-25T23:30:12.823

0

The easiest way to temporarily disable the internet is disable the DHCP Client. The easiest way to do this (on windows XP) is,

  • Right click on your My Computer Icon
  • Click Manage
  • Select Services and Applications
  • Select Services
  • Find DHCP Client

All you have to do is right click on it and hit stop. When you want to enable it again follow the same steps but this time hit start.

This is completely harmless to your computer.

Bishan

Posted 2013-01-25T22:03:41.260

Reputation: 169