[RESOLVED] Disconnecting from internet and network
Results 1 to 12 of 12

Thread: [RESOLVED] Disconnecting from internet and network

  1. #1
    Join Date
    Nov 2001
    Location
    California, USA
    Posts
    2,020

    Resolved [RESOLVED] Disconnecting from internet and network

    When I am not using the internet or working with sensitive data, I disconnect the lan cable that runs from my router to my computer.

    What is the equivalent from a Window perspective or is there a software to do this? Do I just disable the network adapters in Device Manager?

    Thanks
    Originally wanted Millenium Falcon as nick but there is character limitation.
    Falcon Speed = Millenium Falcon = Light Speed

  2. #2
    Join Date
    Apr 2005
    Location
    Maryland, USA
    Posts
    17,806
    Disabling the network adapter(s) works.

  3. #3
    Join Date
    Nov 2001
    Location
    California, USA
    Posts
    2,020
    Thanks Doc!

    Is there a shortcut or bat or vbs file that I can write to toggle enable or disable the network adapters? I believe it can be done in vbs.

    Of course, disabling the network adapters will also disable all LAN activities too right? That is what I want; the equivalent to manually disconnect the cable. Nothing coming in or out.
    Originally wanted Millenium Falcon as nick but there is character limitation.
    Falcon Speed = Millenium Falcon = Light Speed

  4. #4
    Join Date
    Apr 2005
    Location
    Maryland, USA
    Posts
    17,806
    Right now I'm on a XP box and I can simply right-click the Network icon (in the 'Notification' area near the clock) and select Disable.

    And yes, that would stop all traffic through the adapter.

  5. #5
    Join Date
    Jul 2000
    Posts
    4,765
    If applicable,
    Create shortcut to Local Area Connection.
    Cheers.

  6. #6
    Join Date
    Nov 2001
    Location
    California, USA
    Posts
    2,020
    I am on windows 7. No icon next to the clock but I know what you are referring to in xp. Fastest is device manager until I figure the vbscript for it.

    Regardless, thanks for the confirmation on the traffic.
    Originally wanted Millenium Falcon as nick but there is character limitation.
    Falcon Speed = Millenium Falcon = Light Speed

  7. #7
    Join Date
    Apr 2005
    Location
    Maryland, USA
    Posts
    17,806
    To create a shortcut to "Local Area Connection" on your Desktop, click Start, type in "View Network" (without the quotes), select "View Network Connections" from the list and drag the "Local Area Connection" out onto your Desktop. You can now click this new "Local Area Connection" icon to Disable|Enable your connection.

  8. #8
    Join Date
    Nov 2001
    Location
    California, USA
    Posts
    2,020
    I started this thread 2 years ago, looking for a vbs script. If anyone needs it, let me know. I am updating the status.
    Originally wanted Millenium Falcon as nick but there is character limitation.
    Falcon Speed = Millenium Falcon = Light Speed

  9. #9
    Join Date
    Apr 2005
    Location
    Maryland, USA
    Posts
    17,806
    You can use netsh to enable/disable a connection:

    1. At a cmd prompt, type:

      netsh interface show interface

      and press [Enter]. The response you get get back might look something like this (from my Desktop computer):

      Code:
      Admin State    State          Type             Interface Name
      -------------------------------------------------------------------------
      Enabled        Connected      Dedicated        Local Area Connection

      And on my laptop it looks like this:
      Code:
      Admin State    State          Type             Interface Name
      -------------------------------------------------------------------------
      Enabled        Connected      Dedicated        Wireless Network Connection 2

      The part you're interested in is the Name of the connection, which I've highlighted above in red.

    2. Create a new shortcut on your Desktop using that Name in your shortcut command, (I'll use the name from my Desktop computer for this example), like this:

      netsh interface set interface "Local Area Connection" Disable

      and then name the shortcut something like "Disable Network".

    3. Create another new shortcut using that same Name again in the command again, like so:

      netsh interface set interface "Local Area Connection" Enable

      and name it something like "Enable Network".


    That's it. Now you can simply click either icon to Disable or Enable your connection.

  10. #10
    Join Date
    Nov 2001
    Location
    California, USA
    Posts
    2,020
    Very cool Doc. Although I prefer your method through command prompt and shortcut, I have also been doing it through VBScript. This goes into a file with a "vbs" extension.

    Code:
    Option Explicit
    
    Dim ws
    Set ws = WScript.CreateObject( "WScript.Shell" )
    
    Dim oWMIService
    Set oWMIService = GetObject("winmgmts:\\.\root\cimv2")
    
    Dim colAdapters
    Set colAdapters = oWMIService.Execquery("SELECT * FROM Win32_NetworkAdapter WHERE NetConnectionID LIKE '%Local Area Connection%' ")
    
    'PURPOSE: List
    'Dim strNetworkAdapter
    'For Each Adapter in colAdapters
    '    strNetworkAdapter = strNetworkAdapter & Adapter.Name & vbCRLF
    'Next
    'WScript.Echo strNetworkAdapter 
    
    '(-1 is enabled, 0 is disabled)
    Dim strStatus
    Dim errReturn
    If colAdapters.ItemIndex(0).NetEnabled = -1 Then
    	'errReturn = colAdapters.ItemIndex(0).Disable()		'METHOD 1
    	strStatus = "Disabled"
    Else
    	'errReturn = colAdapters.ItemIndex(0).Enable()		'METHOD 1
    	strStatus = "Enabled"
    End If
    
    Call ws.Run("netsh interface set interface name=" & CHR(34) & "Local Area Connection" & CHR(34) & " admin=" & strStatus, 1, False)	'METHOD 2
    
    
    WScript.Echo "NetEnabled = " & strStatus
    
    Set colAdapters = Nothing
    Set oWMIService = Nothing
    Set ws = Nothing
    I can also combine what you have shared, using ws.Run(command prompt), and therefore, it would be one shortcut acting as a toggle switch.

    BTW... I noticed that we can use "Enabled" or "Enable". Either spelling works. Is there any reason behind this?

    Thanks
    Last edited by Falcon Speed; March 4th, 2015 at 01:17 PM.
    Originally wanted Millenium Falcon as nick but there is character limitation.
    Falcon Speed = Millenium Falcon = Light Speed

  11. #11
    Join Date
    Apr 2005
    Location
    Maryland, USA
    Posts
    17,806

  12. #12
    Join Date
    Feb 2000
    Location
    Idaho Falls, Idaho, USA
    Posts
    18,429
    2) Either works probably because a search for Enable finds both in the command line. You might find that Enablex would work also. It also makes for easier use, although that is not generally thought of as a standard Microsoft practice.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •