PDA

Click to See Complete Forum and Search --> : VB (but applies to all) - BEST way to disconnect internet connection


Flip
Jul 6th, 2004, 10:38 PM
After searching for hours to find the perfect way to solve this problem, I thought to myself "Why not just do it through the command prompt? Everything works better in there". So here it is:


RunCommand "RasDial /DISCONNECT"


I have attached the module including the code used to run Command Prompt commands in VB.

Reason why I think this is the best:
I have seen the other APIs like AutoDialHangup and all of that, but I think this way is the best because you don't have to create the connection with any extra code in order to close it. This works every time, with any kind of dialup connection.

Anyone think there is a better, easier way?

Jhd.Honza
Aug 8th, 2004, 08:15 AM
2 things Flip,

1] What if there isn't RAS installed?
2] What if there is internet connection using LAN?

Well I know it wouldn't work in these case, but how disconnect these?

dglienna
Aug 9th, 2004, 12:04 AM
for a brutal approacch, you could try

ipconfig /release

this will disconnect most everything :D

Jhd.Honza
Aug 9th, 2004, 04:29 AM
/release Release the IP address for the specified adapter.


I thought this only releases IP address and if I am on DHCP I will get new one, isn't ?

More over, I am connected using dial-up modem and I've tried it, with this result:


The operation failed as no adapter is in the state permissible for
this operation.

:(

dglienna
Aug 9th, 2004, 09:53 PM
no new ip's until you do IPCONFIG \RENEW
not sure of the effect on STATIC ip's though

maybe you need a combination of the three?

:D

Flip
Aug 14th, 2004, 06:34 PM
I used this do disconnect a shared internet connection (LAN) where the host had a dialup connection, and both computers ran WindowsXP.

As far as I know, RASDIAL is built in to Windows XP (and probabaly earlier versions) - so this should work on any computer.


***I THINK***
"ipconfig /release" won't hangup a dialup internet connection. It just resets some kind of setting that I don't know anything about, and a restart is required for this to take effect anyway.
************


So, Jhd.Honza:
"RasDial /DISCONNECT" should be the command that hangs up your connection, otherwise I have no idea why this isn't working for you :thumb:

mustiback
Feb 10th, 2009, 03:21 AM
Thanks For Sharing...

teguh123
Sep 18th, 2009, 05:56 AM
It works on my connection. But it doesn't work on my client's connection.

He uses asdl and to disconnect he needs username and password. He uses adsl or something.

CLAD genius software can do that though.