6

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?

1
  • 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
    Jan 25, 2013 at 22:10

4 Answers 4

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.

3

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"
1
  • The result is "OK." but my app can still access the web :( Jan 25, 2013 at 23:30
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.

0

Faster way is create a batch file:

@echo off
name of program you went to start with internet off
ipconfig/release
@echo on

when you close that app run this one:

@echo off
ipconfig/renew
@echo on

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .