|
Answer» Hi!
I just wonder if it is possible to write a .bat file that activates my wireless network CONNECTION, and at the same time deactivates the wired Local Connection?
Thanks for answers.
s0br3.The GUI is actually your BEST option. But this piece of doggerel from deep in the snippet closet may help:
Code: [Select]strEnable = "En&able" strDisable = "Disa&ble"
strNetworkFolder = "Network CONNECTIONS" arrConnections = Array("Wireless Network Connection","Local Area Connection") 'Connection names; change if necessary
Set objShell = CreateObject("Shell.Application") Set objCP = objShell.NameSpace(3) 'Control Panel
For Each f In objCP.Items If f.Name = strNetworkFolder Then Set colNetwork = f.GetFolder Exit For End If NEXT
If colNetwork.Items.Count = 0 Then WScript.Quit
For Each strConnection In arrConnections For Each cn In colNetwork.Items If cn.Name = strConnection Then Set conn = cn Exit For End If Next
bEnabled = True For Each verb In conn.Verbs If verb.Name = strEnable Then Set objEnable = verb bEnabled = False Exit for End If If verb.Name = strDisable Then Set objDisable = verb Exit For End If Next If bEnabled = True Then objDisable.DoIt Else objEnable.DoIt End If WScript.Sleep 3000 Next
You'll probably have to change the names of the connections. The line is FLAGGED. This script is designed to toggle the state (enabled->disable or disable->enabled) of the connections named in the array.
Save the script with a vbs extension and run from a command prompt as cscript scriptname.vbs
Good luck. Thank you! Worked perfect!
|