Networking Forums

Networking Forums > Computer Networking > Windows Networking > I am in need of a netsh script that will disable the "Local Area Connection" interface then re-enable that same interface.

Reply
Thread Tools Display Modes

I am in need of a netsh script that will disable the "Local Area Connection" interface then re-enable that same interface.

 
 
Spin
Guest
Posts: n/a

 
      11-02-2005, 04:11 AM
Best gurus,

I am in need of a netsh script that will disable the "Local Area Connection"
interface then re-enable that same interface. A two-liner. Can anyone
help?

--
Spin


 
Reply With Quote
 
 
 
 
Pegasus \(MVP\)
Guest
Posts: n/a

 
      11-02-2005, 05:24 AM

"Spin" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Best gurus,
>
> I am in need of a netsh script that will disable the "Local Area

Connection"
> interface then re-enable that same interface. A two-liner. Can anyone
> help?
>
> --
> Spin
>
>


You might find something here:
http://support.microsoft.com/default...b;EN-US;242468


 
Reply With Quote
 
Todd J Heron
Guest
Posts: n/a

 
      11-02-2005, 09:42 PM
"Spin" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
>Best gurus,
>
>I am in need of a netsh script that will disable the "Local Area
>Connection" interface then re-enable that same interface. A two->liner.
>Can anyone help?
>
>--
>Spin


How about this?
'======== ToggleLanConnection.vbs ========
Const ssfCONTROLS = 3


sConnectionName = "Local Area Connection"


sEnableVerb = "En&able"
sDisableVerb = "Disa&ble"


set shellApp = createobject("shell.application")
set oControlPanel = shellApp.Namespace(ssfCONTROLS)


set oNetConnections = nothing
for each folderitem in oControlPanel.items
if folderitem.name = "Network Connections" then
set oNetConnections = folderitem.getfolder: exit for
end if
next


if oNetConnections is nothing then
msgbox "Couldn't find 'Network Connections' folder"
wscript.quit
end if


set oLanConnection = nothing
for each folderitem in oNetConnections.items
if lcase(folderitem.name) = lcase(sConnectionName) then
set oLanConnection = folderitem: exit for
end if
next


if oLanConnection is nothing then
msgbox "Couldn't find '" & sConnectionName & "' item"
wscript.quit
end if


bEnabled = true
set oEnableVerb = nothing
set oDisableVerb = nothing
s = "Verbs: " & vbcrlf
for each verb in oLanConnection.verbs
s = s & vbcrlf & verb.name
if verb.name = sEnableVerb then
set oEnableVerb = verb
bEnabled = false
end if
if verb.name = sDisableVerb then
set oDisableVerb = verb
end if
next


'debugging displays left just in case...
'
'msgbox s ': wscript.quit
'msgbox "Enabled: " & bEnabled ': wscript.quit


'not sure why, but invokeverb always seemed to work
'for enable but not disable.
'
'saving a reference to the appropriate verb object
'and calling the DoIt method always seems to work.
'
if bEnabled then
' oLanConnection.invokeverb sDisableVerb
oDisableVerb.DoIt
else
' oLanConnection.invokeverb sEnableVerb
oEnableVerb.DoIt
end if


'adjust the sleep duration below as needed...
'
'if you let the oLanConnection go out of scope
'and be destroyed too soon, the action of the verb
'may not take...
'
wscript.sleep 1000


'Courtesy of
'Michael Harris
'Microsoft.MVP.Scripting
'Seattle WA USA
'http://groups.google.com/group/microsoft.public.scripting.vbscript/browse_frm/thread/9f82ef9e7bb12ff3/2b3fab1141c6c93e#2b3fab1141c6c93e
'
'================================================= =========

--
Todd J Heron, MCSE
Windows Server 2003/2000/NT; CCA
----------------------------------------------------------------------------
This posting is provided "as is" with no warranties and confers no rights


 
Reply With Quote
 
Spin
Guest
Posts: n/a

 
      11-03-2005, 12:58 AM
Thanks!!! You 'da man!


"Todd J Heron" <todd_heron(delete)@hotmail.com> wrote in message
news:eYY%23w6$(E-Mail Removed)...

> How about this?
> '======== ToggleLanConnection.vbs ========
> Const ssfCONTROLS = 3



 
Reply With Quote
 
 
 
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Interface Enable/Disable mystery using Netsh ? Vilius Windows Networking 1 10-07-2008 02:41 AM
Frequent "Local Area Connection- A Network Cable is Unplugged" error liu Network Routers 4 03-20-2007 07:47 PM
DHCP IP lease renewal ok, but a new PC can not obtain an IP ("An error occurred while renewing interface Local Area Connection : unable to cotact your DHCP server. Request has timed out.") Soren Mikkelsen Windows Networking 2 06-02-2005 04:43 PM
"Local area connection. A network cable is unplugged" bmancinelli Wireless Networks 2 03-10-2005 11:07 AM
How do I share "Local Area Connection" Internet on XP? zach.bastick@gmail.com Wireless Internet 13 02-05-2005 11:00 AM



1 2 3 4 5 6 7 8 9 10 11