Google Answers Logo
View Question
 
Q: Disable/Inable internet connection via prompt ( Answered,   4 Comments )
Question  
Subject: Disable/Inable internet connection via prompt
Category: Computers > Programming
Asked by: compuplus-ga
List Price: $5.00
Posted: 06 May 2003 10:49 PDT
Expires: 05 Jun 2003 10:49 PDT
Question ID: 200216
How can i disconnect/reconnect my network and the internet connection
using visual basic or the command prompt.

Request for Question Clarification by dogbite-ga on 06 May 2003 10:53 PDT
Hi compuplus-ga,

  I assume your computer is running Windows.
  If so, what version of Windows is your 
  computer running?

         dogbite-ga

Request for Question Clarification by slawek-ga on 06 May 2003 11:27 PDT
Hi compuplus-ga,

The Internet connection is transfered via TCP/IP, which requires an IP
address.  An IP address is assigned to the computer when it connects
to the Internet.

You can see the IP address from the command prompt by using the
ipconfig command.  Different versions of Windows will have slightly
different switches that can be used to release your IP Address, renew
it, or find more information on it.

Most Windows version will allow you to release the IP address via
typing:

ipconfig /release
or
ipconfig /release_all

You can get a list of possible switches by typing ipconfig /?

Once the IP address is released, you will not be able to access the
Internet until you get an IP address.  Again, in most Windows versions
you can achieve that through typing:

ipconfig /renew
or
ipconfig /renew_all

You can try both methods and see which one works, or see the help
files from ipconfig /? to find which one you should be using on your
version of Windows.

Please let me know if this is a satisfactory answer, and if I should
post it officially.

Regards,
slawek-ga

Clarification of Question by compuplus-ga on 06 May 2003 12:27 PDT
Hi slawek-ga
I'm not trying to refresh my ip. I'm tryng to disable my network as if
you go to network connections and right click on the connection and
click disable.

Clarification of Question by compuplus-ga on 06 May 2003 12:27 PDT
Hi, dogbite-ga
I'm using windows XP.

Request for Question Clarification by mathtalk-ga on 22 May 2003 20:44 PDT
Hi, compuplus-ga:

I can show you how to this from VBScript or from a command line, if
you are still interested.

regards, mathtalk-ga

Clarification of Question by compuplus-ga on 22 May 2003 22:10 PDT
Hello mathtalk-ga

Yes. I'm still interested.
Answer  
Subject: Re: Disable/Inable internet connection via prompt
Answered By: mathtalk-ga on 23 May 2003 06:57 PDT
 
Hi, compuplus-ga:

Enabling or disabling a "network connection" by right-clicking has to
do with a specific network adapter (real or virtual).  I will
therefore pursue actions on a single adapter, as opposed to enabling
or disabling your entire network.

The question of doing this programmatically has been explored here:

[Does anyone know of a way to Disable/Enable a NIC through a script?]
http://dbforums.com/arch/195/2002/7/429687

The approach adopted by the original poster (there) was this, a
scripting solution written by Michael Harris, a Microsoft "MVP":

[Re: How to disable-Enable Local area Connection via script]
http://groups.google.com/groups?threadm=OcFYOQD1BHA.2848%40tkmsftngp05

Apparently the script, in order to work reliably under Win2K, is
slightly more complex than it would need to be to work only for WinXP.

If such a scripting approach is not within the bounds of your "using
visual basic or the command prompt", a simpler alternative might be
this:

[FILE: DevCon Command Line Utility Alternative to Device Manager]
http://support.microsoft.com/support/kb/articles/q311/2/72.asp

which let's you download a (non-redistributable) command line utility
devcon.exe to enable or disable network adapters (and other devices;
actually to do pretty much everything you can in Device Manager,
including updating drivers) from the command line.

If you download the file devcon.exe and run it, it self-unzips into
your (current user's) "Local Settings\Temp" directory, or rather into
two subdirectories:

"Local Settings\Temp\i386"

and:

"Local Settings\Temp\ia64"

The latter holds the 64-bit version, which probably we need not
discuss further, and the Temp directory gets a file named EULA.txt for
obvious reasons.

The 32-bit utility devcon.exe in i386 can be run as:

devcon help

or:

devcon help <specific option>

to obtain help with commands and a few examples.  See Microsoft's Web
page above for additional examples and information.

In particular after downloading and unpacking, I ran the command:

devcon listclass net

which showed all network adapters (real and virtual) on my WinXP
laptop.  The first two are the actual hardware adapters, a built in
Ethernet adapter (Intel) and a wireless PCMCIA Ethernet adapter
(Linksys).  The results are presented as a "hardware" device ID
followed by a description:

PCI\VEN_8086&DEV_2449&SUBSYS_30138086&REV_03\4&1351887D&0&40F0:
          Intel(R) PRO/100 VE Network Connection
PCMCIA\INSTANT_WIRELESS_-_NETWORK_PC_CARD-317F\1            :
          Instant Wireless - Network PC CARD

All the remaining "virtual" adapters have id's that begin with
"ROOT...".  Therefore I experimented with the command to disable just
the built in Ethernet adapter:

devcon disable =net PCI\VEN*

which illustrates the use of a wildcard character in the "hardware"
ID.

The output from this command was:

PCI\VEN_8086&DEV_2449&SUBSYS_30138086&REV_03\4&1351887D&0&40F0:
           Disabled
1 device(s) disabled.

Sure enough, when I went to view the network connections, this adapter
was disabled.  I then did the obvious "undo" command:

devcon enable =net PCI\VEN*

which produced the output:

PCI\VEN_8086&DEV_2449&SUBSYS_30138086&REV_03\4&1351887D&0&40F0: 
           Enabled
1 device(s) enabled.

Even before going back to view the network connections again, I knew
the command had worked because a balloon popped up over the "Local
Area Connection" on my taskbar to inform that "A network cable is
unplugged."  (Quite true, since I'm connected by the wireless adapter
to send this message.)

In short the devcon.exe utility does what you want (and much more;
what we call in mathematics the "big hammer" approach) as a "black
box".  If you want to get down into the inner workings of the OS, then
the scripting approach may be attractive.

regards, mathtalk-ga
Comments  
Subject: Re: Disable/Inable internet connection via prompt
From: pokerpro-ga on 06 May 2003 13:52 PDT
 
to stop the service at the command prompt:
net stop "network connections"

to disable the service at the command prompt:
sc config netman start= disabled
Subject: Re: Disable/Inable internet connection via prompt
From: helpandrersearch-ga on 12 May 2003 20:08 PDT
 
I do not think there is a way to disable/enable your internet from VB
Subject: Re: Disable/Inable internet connection via prompt
From: helpandrersearch-ga on 12 May 2003 20:11 PDT
 
Please tel us what version of Windows you're using. If you do, then
all of us can help you better because we will now how that Operating
System works. We assume that you're running windows. Linux has SMB
(Samba).
Subject: Re: Disable/Inable internet connection via prompt
From: helpandrersearch-ga on 12 May 2003 20:12 PDT
 
Sorry about the OS ask. Please disregard it.

Important Disclaimer: Answers and comments provided on Google Answers are general information, and are not intended to substitute for informed professional medical, psychiatric, psychological, tax, legal, investment, accounting, or other professional advice. Google does not endorse, and expressly disclaims liability for any product, manufacturer, distributor, service or service provider mentioned or any opinion expressed in answers or comments. Please read carefully the Google Answers Terms of Service.

If you feel that you have found inappropriate content, please let us know by emailing us at answers-support@google.com with the question ID listed above. Thank you.
Search Google Answers for
Google Answers  


Google Home - Answers FAQ - Terms of Service - Privacy Policy