• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 692
  • Last Modified:

bridge connection vbscript

I would like to write a code (vbscript) that will enable me to connect 2 network interfaces in a bridge.
It will be executed under windows xp.
0
aquasw
Asked:
aquasw
  • 4
  • 2
1 Solution
 
Jared LukerCommented:
You can do that with a simple batch file using the NetSH utility.  You can code it into VB if you want as well..

http://www.microsoft.com/windowsxp/using/networking/expert/crawford_02april22.mspx

netsh bridge set a 1 e

'Start VB
Set WshShell = WScript.CreateObject("WScript.Shell")
wshshell.run "netsh bridge set a 1 e"

'End VB

You will need to change the a and e based on the instructions in that article.
0
 
sr75Commented:
Here is a copy of a script that I have used to automatically run the repair utility (as if I had right clicked on the nic and selected repair.  I believe it will do the same thing with Bridging connections)
'########################################################################################
'#											#
'#	Name:		RepairNIC.vbs							#
'#	Version:	1.0.0								#
'#	Created:	February 26th, 2007						#
'#	Modified:	n/a								#
'#	Description:	This script will run the repair utility on the defined NIC	#
'#											#
'#	Modified:	N/A								#
'#											#
'#	Notes:		This script uses the Control Panel via the shell.application	#
'#			Namespace.  It searches for the Network COnnections folder	#
'#			Then searches for the defined NIC.  It can then perform just 	#
'#			about action that you would normally get when you right-click	#
'#			defined NIC (including Enabling/Disabling the NIC)		#
'#											#
'#			Verb				Script Command			#
'#			----------------------------------------------------------	#
'#			Enable 				En&able (if disabled)		#
'#			Disable				Dis&able (if enabled)		#
'#			Status				Stat&us				#
'#			Repair				Re&pair				#
'#			Bridge Connections		Brid&ge Connections		#
'#			Create Shortcut			Create &Shortcut		#
'#			Delete				???				#
'#			Rename				Rena&me				#
'#			Properties			P&roperties			#
'#											#
'########################################################################################
'---------------------------------------------------------------------------
'
'				Main Function
'
'---------------------------------------------------------------------------
On Error Resume Next
 
 
'================================
'      Define Constants
'================================
Const ssfCONTROLS = 3
Const conVerb = "Re&pair"
 
 
'================================
'        Set Variables
'================================
strConnection = "External"
 
Set WShell = CreateObject("Wscript.Shell")
set Shell = CreateObject("Shell.Application")
set objCP = Shell.Namespace(ssfCONTROLS)
set objNetCon = Nothing
set objLanCon = Nothing
 
 
'================================
'       Get Object
'================================
For Each Folder in objCP.items
	If Folder.Name = "Network Connections" then
		set objNetCon = Folder.GetFolder: Exit For
	End If
Next
 
If objNetCon is Nothing then
	wscript.quit
End If
 
 
'================================
'         Perform NIC Repair
'================================
For Each Connection in objNetCon.Items
	If lcase(Connection.Name) = lcase(strConnection) then
		set objConnection = Connection
		strStatus = ObjConnection.invokeverb(conVerb)
		Wshell.popup strstatus,30
 
	End If
Next
 
 
'================================
'        Perform Clean Up
'================================
Set WShell = Nothing
set Shell = Nothing
set objCP = Nothing
set objNetCon = Nothing
set objLanCon = Nothing

Open in new window

0
Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

 
Jared LukerCommented:
sr75...

Do you know if that script works on Vista?  That would be a good one for my wife to run when  the wireless card on our Kitchen PC forgets its job.
0
 
sr75Commented:
I tested it on Vista and it didn't work, but it might help point you in the right direction for a script that will work on Vista.
0
 
Jared LukerCommented:
ok... thanks

aquasw... sorry to derail your thread...

we now continue with our regularly scheduled program...
0

Featured Post

Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

  • 4
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now