Go Back   TechArena Community > Technical Support > Computer Help > Windows Vista > Vista Help
Become a Member!
Forgot your username/password?
Tags Active Topics RSS Search Mark Forums Read

Sponsored Links



netsh to set IP address on vista..

Vista Help


Reply
 
Thread Tools Search this Thread
  #1  
Old 10-02-2008
pdabak@yahoo.com
 
Posts: n/a
netsh to set IP address on vista..

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

Reply With Quote
  #2  
Old 10-02-2008
Kerry Brown
 
Posts: n/a
Re: netsh to set IP address on vista..

I'm not sure but I think you'd need to add the ipv4 parameter in there
somewhere. At a command prompt type "netsh interface ?" for details.
Reply With Quote
  #3  
Old 10-02-2008
Mark L. Ferguson
 
Posts: n/a
Re: netsh to set IP address on vista..

You probably failed to open the Command Prompt 'run as administrator'
Start/rightclick Command Prompt icon.
Reply With Quote
  #4  
Old 11-02-2008
pdabak@yahoo.com
 
Posts: n/a
Re: netsh to set IP address on vista..

I am running in administrator context. As I said, if I specify "Local
Area Connection", it works fine.
Reply With Quote
  #5  
Old 11-02-2008
pdabak@yahoo.com
 
Posts: n/a
Re: netsh to set IP address on vista..

I tried specifying ipv4 instead of ip as follows, however, it still
failed with the same error.

netsh interface ipv4 set address IP_ADAPTER_INFO.AdapterName static
10.6.36.159 255.255.0.0 10.6.0.1 1

I think that "netsh interface ip" is same as "netsh interface ipv4"
i.e. The default is always ipv4.

However, I noticed one interesting thing. On vista, one can specify
interface name OR interface index to "netsh interface ip set address"
command. So when I used following command, it worked.

netsh interface ip set address IP_ADAPTER_INFO.Index static
10.6.36.159 255.255.0.0 10.6.0.1 1

So basically I specified IP_ADAPTER_INFO.Index instead of
IP_ADAPTER_INFO.AdapterName and it worked. However, I am not sure if
this is the right way to do it?

I find adapter and interface terms being used interchangably and I
find it very confusing.
Reply With Quote
  #6  
Old 11-02-2008
Kerry Brown
 
Posts: n/a
Re: netsh to set IP address on vista..

I tried specifying ipv4 instead of ip as follows, however, it still
failed with the same error.

netsh interface ipv4 set address IP_ADAPTER_INFO.AdapterName static
10.6.36.159 255.255.0.0 10.6.0.1 1

I think that "netsh interface ip" is same as "netsh interface ipv4"
i.e. The default is always ipv4.

However, I noticed one interesting thing. On vista, one can specify
interface name OR interface index to "netsh interface ip set address"
command. So when I used following command, it worked.

netsh interface ip set address IP_ADAPTER_INFO.Index static
10.6.36.159 255.255.0.0 10.6.0.1 1

So basically I specified IP_ADAPTER_INFO.Index instead of
IP_ADAPTER_INFO.AdapterName and it worked. However, I am not sure if
this is the right way to do it?

I find adapter and interface terms being used interchangably and I
find it very confusing.


Interesting. Have you tried this on an XP computer to see if it's backwards
compatible?
Reply With Quote
  #7  
Old 12-02-2008
pdabak@yahoo.com
 
Posts: n/a
Re: netsh to set IP address on vista..

Yes, there is no issue on XP. The "netsh interface ip set address
IP_ADAPTER_INFO.AdapterName static 10.6.36.159 255.255.0.0 10.6.0.1 1"
command works fine in XP.

Thanks.
-Prasad
Reply With Quote
Reply

  TechArena Community > Technical Support > Computer Help > Windows Vista > Vista Help
Tags: ,



Thread Tools Search this Thread
Search this Thread:

Advanced Search


Similar Threads for: "netsh to set IP address on vista.."
Thread Thread Starter Forum Replies Last Post
Netsh winsock reset Saaz Operating Systems 4 08-12-2011 06:31 AM
Windows 7 WLAN netsh command Mariah-Simpson Operating Systems 5 12-04-2010 11:49 PM
netsh winsock reset command for Mac OS X CossFire Operating Systems 4 24-02-2010 11:04 PM
Can you query a DHCP server using netsh to display the IP address assigned to a MAC? djackson88 Windows Server Help 1 10-07-2009 05:46 PM
How to Use the Netsh.exe and NETSH Command to Change from Static IP in win2000 karunakar Networking & Security 3 01-01-2009 04:59 PM


All times are GMT +5.5. The time now is 01:56 PM.