views:

101

answers:

3

hey i know that on some computers you can cut off the wifi with a buttion and i want to do that with my desktop but it's not wireless. is there a way to in code block my computer from the internet then unblock later. anyway i can do this?

A: 

A rather brute force way on windows if you're getting your address via DHCP is to just make a call to ipconfig /release and ipconfig /renew when you want your access back.

Andrew
uhh... could i use that in my program?
blood
Of course. Just use [Process](http://msdn.microsoft.com/en-us/library/system.diagnostics.process.aspx) to start the ipconfig executable.
Michael Todd
Took the words right out of my mouth, @Andrew:
ItzWarty
Still, calling external executables to carry out a task that can be done easily with APIs (see Jerry Coffin's answer) is generally bad programming practice.
Matteo Italia
+4  A: 

Try to use WMI - Windows Management Instrumentation to disable network connections.

WMI is visual basic / scripting friendly COM-technology based API and doesn't provide greate abilities though. But hope it helps

Andrew Florko
+2  A: 

One possibility would be to use IpReleaseAddress to cut the connection, and IpRenewAddress to re-start it. Another possibility would be to use SetIfEntry to disable/enable the network interface.

Jerry Coffin