Jump to content











Photo
- - - - -

How can I (easily) connect/disconnect a LAN/Ethernet connection?


  • Please log in to reply
26 replies to this topic

#26 gbrao

gbrao

    Frequent Member

  • Advanced user
  • 474 posts
  •  
    India

Posted 16 May 2017 - 03:25 AM

Just came across this : NetDisabler

http://www.sordum.or...-disabler-v1-0/

 

 

Usage is very simple , there are 3 Internet blocking methods yo can choose one/all of them or you can use a combination
1. Disable devices
2. Block with DNS
3. Block with Windows firewall

After selecting use Apply button to complete the Operation, to bring the Internet back just remove the ticks and apply them. Under menu button you can choose your Network Adapers , you can set a password , open Device Manager, Network Connections or Firewall settings

 

I'll try it out on my other "test" PC - these days I'm slightly paranoid.



#27 Wonko the Sane

Wonko the Sane

    The Finder

  • Advanced user
  • 16066 posts
  • Location:The Outside of the Asylum (gate is closed)
  •  
    Italy

Posted 16 May 2017 - 02:12 PM

Well, there is also the Nirsoft tool, working from wIndows 2000 up to 10, I thought we were talking "built-in" (and command line):

http://www.nirsoft.n...interfaces.html

 

Like most Nirsoft utilities it is possible to parse the output by saving to an empty-name file and piping it, example:

NetworkInterfacesView.exe  /stab "" | Find "" /v

and it has a /enable and /disable switch alright (and it has both 32 and 64 bit version).

 

It correctly filters the "real" NIC's :) but the "generic" issue when more than one adapter is present remains, the Status column has values "Operational" and "Hardware Disconnected", but nothing prevents someone to have two or more NIC's "Operational", so one needs anyway to manually find the "right" interface (by means of the GUI) and then use its "localized" connection name, the manufacturer's "device name" or - advised - its GUID in the enable/disable command.

 

Example:

@ECHO OFF
SETLOCAL ENABLEEXTENSIONS ENABLEDELAYEDEXPANSION
SET /A Counter=1
::Get Column Names
FOR /F "tokens=* delims=," %%A IN ('NetworkInterfacesView.exe /scomma "" ^| FIND /v ""') DO SET Columns=%%A&GOTO :Get_Index
:GET_Index
CALL :Col_names %Columns: =_%
FOR /F "skip=1 tokens=* delims=," %%? IN ('NetworkInterfacesView.exe /scomma "" ^| FIND /v ""') DO SET Columns=%%?&CALL :prettify
GOTO :EOF


:Col_names
::Device_Name
::Interface_GUID
::MTU
::Lease_Obtained_Time
::Lease_Terminates_Time
::T1_Time
::T2_Time
::Registry_Time
::Status
::MAC_Address
::Connection_Name
::IP_Address
::Subnet_Mask
::Default_Gateway
::Name_Servers
::DHCP_Enabled
::DHCP_Server
::Instance_ID

IF %1.==. SET /A Counter=1&GOTO :EOF
SET %1=Col_x%Counter%
SET Col_x%Counter%=%1
SET /A Counter+=1
SHIFT
GOTO :Col_names

GOTO :EOF

:prettify
SET Columns=%Columns:&=_AND_%
SET Columns=%Columns: =_%
SET Columns=%Columns:,,=,N/A,%
SET Columns=%Columns:,,=,N/A,%
FOR /L %%A IN (1,1,18) DO SET Col_x%%A=N/A
CALL :Number_Cols %Columns%
IF !%IP_Address%!==N/A SET %IP_Address%=xxx.xxx.xxx.xxx
SET %IP_Address%=        !%IP_Address%!
SET %IP_Address%=!%IP_Address%:~-15,15!
IF !%Status%!==Operational SET %Status%=Y
IF !%Status%!==Hardware_Disconnected SET %Status%=N
IF !%MAC_Address%!==N/A SET %MAC_Address%=XX-XX-XX-XX-XX-XX
SET Line=!%Status%! !%MAC_Address%! !%Interface_GUID%! !%Device_Name%:_= !
ECHO %Line:~0,79%


GOTO :EOF

:Number_Cols
IF %1.==. SET /A Counter=1&GOTO :EOF
SET Col_x%Counter%=%1
SET /A Counter+=1
SHIFT
GOTO :Number_Cols

:duff:

Wonko


  • gbrao likes this




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users