Hello,
I need to set the IP address of the network adapter given it's MAC
address.
To do this I use GetAdaptersInfo API from IPHLPAPI.DLL to enumerate
network adapters and then compare IP_ADAPTER_INFO.Address to the MAC
address I am looking for. Once I get a match, I extract
IP_ADAPTER_INFO.AdapterName and then I pass it to netsh command as
follows
netsh interface ip set address IP_ADAPTER_INFO.AdapterName static
10.6.36.159 255.255.0.0 10.6.0.1 1
The IP_ADAPTER_INFO.AdapterName is in the form of a GUID viz.
{650B810A-0C51-4147-B1C4-0076A36B1C5A}
This all works fine on Windows 2000/2003/XP. However on Vista, it
fails with the following error.
"The filename, directory name, or volume label syntax is incorrect."
It seems that vista only supports specifying connection name viz.
"Local Area Connection" and is not backward compatible.
Now the question I have is:
Is there any other way to map the MAC address OR AdapterName in GUID
format to connection name? I know that its possible to do so through
WMI, I want avoid using WMI. Since WMI is able to provide this
mapping, there must be some way to do it.
Thanks.
-Prasad
Bookmarks