QuickNIC

Recommended Posts

spudw2k 168

spudw2k 168

A co-worker of mine was working remotely yesterday and asked if I knew of a way to easy and quickly enable/disable his wireless card rather than the tediousness of opening Network Connections, right-click and (En/Dis)able. I found a vbscript that uses a Shell object to do essentially the same thing, but I took the liberty of improving it. I converted the script to AutoIt to increase functionality and add a gui.

I designed it to run the in systemtray for ease. Take a look and hopefully someone else will find it useful.

---update---

Code has been updated. Download version 2 below on my second post. The original code is left available for reference.

Share this post

Link to post

Share on other sites

sulfurious 0

sulfurious 0

Here is what I have been using for a while. VBS, but same difference. This is for XP, I have a different one for 2k, small differences.

Sul.

'~ Toggle a SPECIFIED NIC on or off
Option Explicit
Dim objShell
Dim objCP, objEnable, objDisable, colNetwork
Dim clsConn, clsLANConn, clsVerb
Dim strNetConn, strConn, strEnable, strDisable
Dim bEnabled, bDisabled
strNetConn = "Network Connections"
strConn = "name of your network adapter here"
strEnable = "En&able"
strDisable = "Disa&ble"
Set objShell = CreateObject("Shell.Application")
Set objCP = objShell.Namespace(3) 'Control Panel
Set colNetwork = Nothing
For Each clsConn in objCP.Items
If clsConn.Name = strNetConn Then
Set colNetwork = clsConn.getfolder
Exit For
End If
Next
If colNetwork is Nothing Then
WScript.Echo "Network folder not found"
WScript.Quit
End If
Set clsLANConn = Nothing
For Each clsConn in colNetwork.Items
'~ ‘In case the LAN is named "connection 2", etc.
If Instr(LCase(clsConn.name),LCase(strConn)) Then
Set clsLANConn = clsConn
Exit For
End If
Next
If clsLANConn is Nothing Then
WScript.Echo "Network Connection not found"
WScript.Quit
End If
bEnabled = True
Set objEnable = Nothing
Set objDisable = Nothing
For Each clsVerb in clsLANConn.verbs
If clsVerb.name = strEnable Then
Set objEnable = clsVerb
bEnabled = False
End If
If clsVerb.name = strDisable Then
Set objDisable = clsVerb
End If
Next
If bEnabled Then
objDisable.DoIt
Else
objEnable.DoIt
End If
'~ Give the connection time to stop/start
WScript.Sleep 1000
WScript.Quit