I have scripted ConnInterface.bat to enable (connect) or disable (disconnect) an interface, like Local Area Connection, from the command-line.

ConnInterface.bat uses Cnic.exe which you must extracted from TechniquesForSimp2006_05.exe and stored in a folder that is in your path.

The syntax for using ConnInterface.bat is:

\[call\] ConnInterface Action InterfaceName Status

where:

<b>Action</b>    is a <b>C</b> to connect, a <b>D</b> to disconnect, or and <b>S</b> to only return status.

<b>Interface</b> is the name of the interface, like "<b>Local Area Connection</b>".

<b>Status</b>    is a <a href="/article/tips/tip.aspx?id=5535">call directed environment variable</a> that will contain the interface status
          after the <b>Action</b> is performed, either <b>C</b> for connected, <b>D</b> for disconnected, or <b>E</b> for error.
NOTE: See tip 10620 » How can I rename an interface (Local Area Connection) from the command-line?
NOTE: See tip 3378 » How can I change the Local Area Connection name and/or the connection icon on the taskbar, using the registry?

ConnInterface.bat contains:

@echo off
if \{%3\}==\{\} @echo Syntax: ConnInterface Action InterfaceName Status&goto :EOF
setlocal
set Action=%1
set IFN=%2
set Action=%Action:"=%
if /i "%action%" EQU "C" goto con
if /i "%action%" EQU "D" goto dis
if /i "%action%" EQU "S" goto sta
@echo Error: ConnInterface %1 %2 %3 - Action is must be C,D, or S
endlocal
goto :EOF
:con
set IC=cnic %IFN% -c -s -v
goto doit
:dis
set IC=cnic %IFN% -d -s -v
goto doit
:sta
set status=E
set wrk=E
for /f "Tokens=*" %%s in ('cnic %IFN% -s -v^|find "connected"') do (
 set wrk=%%s
)
set wrk=%wrk:"=%
if "%wrk%" EQU "E" goto finish
set wrk=%wrk:*disconnected=D%
if "%wrk%" EQU "D" set status=D&goto finish
set wrk=%wrk:*connected=C%
if "%wrk%" EQU "C" set status=C
:finish
endlocal&set %3=%status%
goto :EOF
:doit
set status=E
for /f "Tokens=*" %%s in ('%IC%^|find "Operation succeded"') do (
 set status=Y
)
if "%status%" EQU "E" goto finish
goto sta