I have found a script at which will allow me to enable/disable a network connection.
When I run the script i get the following error, (18, 24) Windows Script Host: The value for the attribute is not valid : progid
I Don't really know anything about vbscript and would really appreciate a little help on this. Im sure it is a has a simple solution. Thanks
Code:
<package>
<comment>
NICToggle.wsf
This script looks at your ‘Local Area Connection’
and enables it if disabled, disables it if enabled.
</comment>
<job>
<runtime>
<description>
Script for toggling network connection on/off
</description>
<example>
C:\>cscript ToggleNIC.wsf
</example>
</runtime>
<object id=”objShell” progid=”Shell.Application”/>
<script language=”VBScript”>
‘Toggle NIC on or off
Option Explicit
Dim objCP, objEnable, objDisable, colNetwork
Dim clsConn, clsLANConn, clsVerb
Dim strNetConn, strConn, strEnable, strDisable
Dim bEnabled, bDisabled
strNetConn = “Network Connections”
strConn = “Local Area Connection”
strEnable = “En&able”
strDisable = “Disa&ble”
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
</script>
</job>
</package>
When I run the script i get the following error, (18, 24) Windows Script Host: The value for the attribute is not valid : progid
I Don't really know anything about vbscript and would really appreciate a little help on this. Im sure it is a has a simple solution. Thanks