Jump to content

mobious99

Member
  • Posts

    28
  • Joined

  • Last visited

  • Donations

    0.00 USD 
  • Country

    United States

Everything posted by mobious99

  1. I wrote a vbscript that does most of the netsh stuff that way it will ask you what you want it also will do the domain stuff / wins etc one of the tricks that I do with netsh is to get the network adapter and then change it based on the driver it's using. for example the one that I have here is for hp nic teams. dim stripaddr dim strsubnet dim strgateway dim strdns1 dim strdns2 dim strdns3 dim strwins1 dim strwins2 strComputer = "." Set objWMIService = GetObject("winmgmts:" _ & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2") Set colItems = objWMIService.ExecQuery("Select * from Win32_NetworkAdapter where Name = 'HP Network Teaming Virtual Miniport Driver'") For Each objItem in colItems 'Wscript.Echo "Net Connection ID: " & objItem.NetConnectionID strnicname=objItem.NetConnectionID next 'strnicname = objItem.NetConnectionID 'wscript.echo strnicname Const NETWORK_CONNECTIONS = &H31& Set objShell = CreateObject("Shell.Application") Set objFolder = objShell.Namespace(NETWORK_CONNECTIONS) Set colItems = objFolder.Items For Each objItem in colItems If objItem.Name = strnicname Then objItem.Name = "Public Team" End If Next stripaddr = InputBox("Please enter the IP address:","Enter IP Address for the Team", ip ) strsubnet = InputBox("Please enter subnetmask:","Enter Team subnetmask", subnet ) strgateway = InputBox("Please enter the default gateway:","Enter Team Default gateway", gateway ) 'strdns1 = InputBox("Please enter the default first dns server:","Enter Dns Server1", strdns1 ) 'strdns2 = InputBox("Please enter the default Second dns server:","Enter Dns Server2", strdns2 ) 'strdns3 = InputBox("Please enter the default Third dns server:","Enter Dns Server3", strdns3 ) 'strwins1 = InputBox("Please enter the first wins server:","Enter wins server 1", strwins1 ) 'strwins2 = InputBox("Please enter the second wins server:","Enter Wins server2", strwins2 ) 'stripaddr = "192.168.1.49" 'strsubnet = "255.255.255.0" 'strgateway = "192.168.1.1" strdns1 = "1.1.1.1" strdns2 = "1.1.1.1" 'strdns3 = "1.1.1.1" strwins1 = "1.1.1.1" strwins2 = "1.1.1.1" strcommand = "netsh interface ip set address name=""Public Team"" source=static " & stripaddr & " " & strsubnet & " " & strgateway & " 1" strcommand1 = "netsh interface ip set dns ""Public Team"" static addr="&strdns1&" register=PRIMARY" strcommand2 = "netsh interface ip add dns ""Public Team"" addr="&strdns2&" index=2" strcommand3 = "netsh interface ip add dns ""Public Team"" addr="&strdns3&" index=3" strcommand4 = "netsh interface ip set wins name=""Public Team"" source=static addr="&strwins1&"" strcommand5 = "netsh interface ip add wins name=""Public Team"" addr="&strwins2&" index=2" 'WScript.Echo "Running command: " & strCommand 'WScript.Echo "Running command: " & strCommand1 'WScript.Echo "Running command: " & strCommand2 'WScript.Echo "Running command: " & strCommand3 'WScript.Echo "Running command: " & strCommand4 'WScript.Echo "Running command: " & strCommand5 set objshell = wscript.createobject("wscript.shell") objshell.run ("%comspec% /c " & strcommand) ,0,true set objshell = wscript.createobject("wscript.shell") objshell.run ("%comspec% /c " & strcommand1) ,0,true set objshell = wscript.createobject("wscript.shell") objshell.run ("%comspec% /c " & strcommand2) ,0,true set objshell = wscript.createobject("wscript.shell") objshell.run ("%comspec% /c " & strcommand3) ,0,true set objshell = wscript.createobject("wscript.shell") objshell.run ("%comspec% /c " & strcommand4) ,0,true set objshell = wscript.createobject("wscript.shell") objshell.run ("%comspec% /c " & strcommand4) ,0,true set objshell = wscript.createobject("wscript.shell") objshell.run ("%comspec% /c " & strcommand5) ,0,true 'now to add the dns suffixes On Error Resume Next strComputer = "." Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2") Set colNetCards = objWMIService.ExecQuery _ ("Select * From Win32_NetworkAdapterConfiguration Where where Name = 'HP Network Teaming Virtual Miniport Driver'") Set objNetworkSettings = objWMIService.Get("Win32_NetworkAdapterConfiguration") arrDNSSuffixes = Array("somewhere.com", "somewhere.net", "yoursite.com", "another.com") objNetworkSettings.SetDNSSuffixSearchOrder(arrDNSSuffixes) 'CODE 1 ************************** ' Correctly sets IP, Subnet, DNS, Gateway 'On Error Resume Next ' WINS Section ' 0 : enable NetBIOS via DHCP ' 1 : enable NetBIOS ' 2 : disable NetBIOS iNetBios = 1 strComputer = "." Set objWMIService = GetObject("winmgmts:" _ & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2") Set colNetAdapters = objWMIService.ExecQuery _ ("Select * from Win32_NetworkAdapterConfiguration where where Name = 'HP Network Teaming Virtual Miniport Driver'") ' WINS Section For Each objNetAdapter in colNetAdapters objNetAdapter.SetTCPIPNetBIOS(iNetBios) Next
  2. sorry to ask but do you have an example?
  3. Hi, I've been working on automating teaming at work and here's what I'm trying to do - read existing network connections names "local area connection1, 2, 3, 4" - save the names somewhere - use netsh to configure the names based upon that name lets say I always want network connection 4 to have the same settings. the problem that I have (other than spelling) is that I've got a bunch of people at work that have named the connections to different things so I'm kind of stuck, I need to modify that connection but w/o knowing the name I can't use netsh to do it.. any ideas?
×
×
  • Create New...