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
2010-05-23 04:59:08
uhh... could i use that in my program?
blood
2010-05-23 05:05:24
Of course. Just use [Process](http://msdn.microsoft.com/en-us/library/system.diagnostics.process.aspx) to start the ipconfig executable.
Michael Todd
2010-05-23 05:10:56
Took the words right out of my mouth, @Andrew:
ItzWarty
2010-05-23 05:26:28
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
2010-05-23 12:36:04
+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
2010-05-23 05:05:25
+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
2010-05-23 05:25:05