Jump to content

Recommended Posts

Posted

@benched42 : thanks to use my UDF.

You're right, _GetNetworkAdapterInfos()  does not return the same list of adapters than _GetNetworkAdapterList() , because one uses WMI and the other one uses the registry. To make sense, it should return the same list of adapters, I agree. So, I just edited the UDF (download link), so it returns the same list of adapters.

Can you try it please ?

Posted

I have no idea about how to do it using AutoIt (without using any external tool).
I found this article which refers to bridgeutil.exe . It seems this tool could help you to do what you want.

@Jos : https://www.windowscentral.com/how-set-and-manage-network-bridge-connection-windows-10

 

  • 3 months later...
Posted (edited)

Capture.JPGI finally get to use your UDF. I  am using Windows 10, I changed  ' Local Area Network' to  'Ethernet', however I am still not able to display the DNS and WINS IP

 

 

Capture.JPG

Capture1.JPG

Capture2.JPG

Edited by antonioj84
Posted

Correction, UDF works like a charm. You have to  use the current adapter. not both at the same time.

I was using my wireless adapter as default, once I close wireless and defaulted to  Ethernet  everything work including DNS and WINS

  • 2 months later...
Posted (edited)

How would one detect if a network interface is "Identifying..." or IPv4/IPv6: "No Network Access," "No Internet Access", "Internet"

perferrably without wmi

Edited by Biatu

What is what? What is what.

  • 2 months later...
  • 10 months later...
Posted (edited)

@jguinch I am having an issue with this UDF. Not sure if it is a bug or what. I used the _GetNetworkAdapterInfos() to see which adapters are available and which adapter(s) are connected. The machines I am currently working with, has two ethernet nics, with identical Windows 10 images. Each machine shows "Ethernet 2" and "Ethernet 3" in the "Network adapters" section of the control panel. The _GetNetworkAdapterInfos() function performs correctly and retrieves the necessary information I need to determine which adapter I want to assign a static IP to. In the case of this deployment, I have 200 machines that I want to assign a static IP to, based on a numerical portion of the computer name. The issue I'm having is when I use the functions _EnableStatic and _SetGateways. No matter which nic I pass, it assigns the static to "Ethernet 2".  I've tried using the info returned from _GetNetworkAdapterInfos() in [n][8], and I've tried passing "Ethernet 3" as a string, and it still assigns it to "Ethernet 2". 

 

 

#include <Network.au3>

local $isConnected, $availableNics, $ClientID

$ClientID= StringTrimLeft(@ComputerName, 3)
if $ClientID<100 then $ClientID= StringTrimLeft(@ComputerName, 4)
if $ClientID<10 then $ClientID= StringTrimLeft(@ComputerName, 5)


$availableNics= _GetNetworkAdapterInfos()
$t=UBound($availableNics, 1)
$n=0


Do

If $availableNics[$n][9]=2 Then
    $isConnected=$availableNics[$n][8]
    ExitLoop
Else
    ;I did this in case there was already a static, within the same subnet, assigned to a nic that wasnt connected so that
    ;it would not error when assigning a static to the connected nic, which appears not to work at all, even when ran seperately 
    ;in a seperate script designed to set all nics as dynamic, ahead of running the static assignement script.

    _EnableDHCP($availableNics[$n][8])
    _EnableDHCP_DNS($availableNics[$n][8])
EndIf
$n=$n+1

Until $n=$t-1

;This MsgBox displays the appropriate nic that should be affected
MsgBox(0,"192.168.100." & $ClientID & " Adapter: " & $isConnected, "",10)

_EnableStatic($isConnected, "192.168.100." & $ClientID, "255.255.255.0")
_SetGateways($isConnected, "192.168.100.100")
shutdown(2)

 

Edited by BenfnJovi
Posted

Nothing jumping out at me in regards to why the _EnableStatic and _SetGateway functions are working.

Are you positive the IP and network names are valid?  

 

 

Posted

Please, can you try this code :

#RequireAdmin
#Include "Network.au3"

_EnableStatic("Ethernet 2", "192.168.100.252", "255.255.255.0")
_EnableStatic("Ethernet 3", "192.168.100.253", "255.255.255.0")

and then, confirm that you have just one adapter with the good ip address

Posted

@jguinch... I apologize about just getting back to you on this. I had to finish that deployment, by setting the statics manually and have been busy with other things since. I still have a need to get this working properly for future deployments. I ran your script, as you requested and get the same results. "Ethernet 2" was assigned with ".253" and "Ethernet 3" was unaffected... Any other suggestions?

 

 

Posted
On 2/27/2019 at 11:01 PM, spudw2k said:

Nothing jumping out at me in regards to why the _EnableStatic and _SetGateway functions are working.

Are you positive the IP and network names are valid?  

 

 

@spudw2k

Positive the IP's are valid. I have full control over the network. I installed the dhcp server service, and configured all things related to the LAN. At the time of my first post, I only had 64 clients receiving IP's above .100, so everything below .100 would've been valid... If it weren't, it wouldn't have assigned the intended IP to "Ehternet 2", wouldn't you think? Windows will warn if you are using a gateway entry already in use by another nic, even on an inactive nic, and a warning dialog, requiring user confirmation, appears.

To answer your second question, I'm not using the network names, I'm using the windows name assigned to each card...ie: "Ethernet 2", "Ethernet 3".

Posted (edited)

Just wanted to confirm.  Your parsing of the hostname was the only thing I could see as possibly causing an IP format issue, but without seeing the hostnames or examples I was left to speculate.  If you're good, then...you're good.  Maybe you could result to using netsh instead an automating it that way, if there is indeed something inherent and unidentified in the UDF causing issues.

Edited by spudw2k
  • 2 years later...
Posted

Local $colNetAdapter = $objWMIService.ExecQuery($sQueryNetAdapter, "WQL", $wbemFlagReturnImmediately + $wbemFlagForwardOnly)
Local $colNetAdapter = $objWMIService.ExecQuery($sQueryNetAdapter, "WQL", ^ ERROR

 

Can someone help me with this?

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...