Windows Vista Tips

Windows Vista Tips > Newsgroups > Windows Vista General Discussion > netsh to set IP address on vista..

Reply
Thread Tools Display Modes

netsh to set IP address on vista..

 
 
pdabak@yahoo.com
Guest
Posts: n/a

 
      02-10-2008
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
 
 
 
 
Kerry Brown
Guest
Posts: n/a

 
      02-10-2008
<> wrote in message
news:3c212b13-c827-4ade-bec2-...
> 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.
>



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.

--
Kerry Brown
Microsoft MVP - Shell/User
http://www.vistahelp.ca/phpBB2/



 
Reply With Quote
 
Mark L. Ferguson
Guest
Posts: n/a

 
      02-10-2008
You probably failed to open the Command Prompt 'run as administrator'
Start/rightclick Command Prompt icon.

--
Was this helpful? Then click the Ratings button. Voting helps the web
interface.
http://www.microsoft.com/wn3/locales....htm#RateAPost

Mark L. Ferguson

..
<> wrote in message
news:3c212b13-c827-4ade-bec2-...
> 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
 
pdabak@yahoo.com
Guest
Posts: n/a

 
      02-11-2008
On Feb 10, 11:25*pm, "Mark L. Ferguson"
<MarkLFergu...@discussions.microsoft.com> wrote:
> You probably failed to open the Command Prompt 'run as administrator'
> Start/rightclick Command Prompt icon.
>
> --
> Was this helpful? Then click the Ratings button. Voting helps the web
> interface.http://www.microsoft.com/wn3/locales....htm#RateAPost
>
> Mark L. Ferguson
>
> .<pda...@yahoo.com> wrote in message
>
> news:3c212b13-c827-4ade-bec2-...
>
>
>
> > 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 tonetshcommand as
> > follows

>
> >netshinterface 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- Hide quoted text -

>
> - Show quoted text -


Hello,

I am running in administrator context. As I said, if I specify "Local
Area Connection", it works fine.

Thanks.
-Prasad

 
Reply With Quote
 
pdabak@yahoo.com
Guest
Posts: n/a

 
      02-11-2008
On Feb 10, 10:58*pm, "Kerry Brown" <ke...@kdbNOSPAMsys-tems.c*a*m>
wrote:
> <pda...@yahoo.com> wrote in message
>
> news:3c212b13-c827-4ade-bec2-...
>
>
>
>
>
> > 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 tonetshcommand as
> > follows

>
> >netshinterface 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 onVista, it
> > fails with the following error.

>
> > "The filename, directory name, or volume label syntax is incorrect."

>
> > It seems thatvistaonly 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.

>
> I'm not sure but I think you'd need to add the ipv4 parameter in there
> somewhere. At a command prompt type "netshinterface ?" for details.
>
> --
> Kerry Brown
> Microsoft MVP - Shell/Userhttp://www.vistahelp.ca/phpBB2/- Hide quoted text -
>
> - Show quoted text -


Hello,

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.

Thanks.
-Prasad



 
Reply With Quote
 
Kerry Brown
Guest
Posts: n/a

 
      02-11-2008
<> wrote in message
news:eebf2734-a9da-4580-9874-...
> > 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 tonetshcommand as
> > follows

>
> >netshinterface 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 onVista, it
> > fails with the following error.

>
> > "The filename, directory name, or volume label syntax is incorrect."

>
> > It seems thatvistaonly 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.

>
> I'm not sure but I think you'd need to add the ipv4 parameter in there
> somewhere. At a command prompt type "netshinterface ?" for details.
>
> --
> Kerry Brown
> Microsoft MVP - Shell/Userhttp://www.vistahelp.ca/phpBB2/- Hide quoted
> text -
>
> - Show quoted text -


Hello,

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?

--
Kerry Brown
Microsoft MVP - Shell/User
http://www.vistahelp.ca/phpBB2/



 
Reply With Quote
 
pdabak@yahoo.com
Guest
Posts: n/a

 
      02-12-2008
On Feb 11, 8:22*pm, "Kerry Brown" <ke...@kdbNOSPAMsys-tems.c*a*m>
wrote:
> <pda...@yahoo.com> wrote in message
>
> news:eebf2734-a9da-4580-9874-...
>
>
>
>
>
> > > 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 tonetshcommand as
> > > follows

>
> > >netshinterface 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 onVista, it
> > > fails with the following error.

>
> > > "The filename, directory name, or volume label syntax is incorrect."

>
> > > It seems thatvistaonly 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.

>
> > I'm not sure but I think you'd need to add the ipv4 parameter in there
> > somewhere. At a command prompt type "netshinterface ?" for details.

>
> > --
> > Kerry Brown
> > Microsoft MVP - Shell/Userhttp://www.vistahelp.ca/phpBB2/-Hide quoted
> > text -

>
> > - Show quoted text -

>
> Hello,
>
> I tried specifying ipv4 instead of ip as follows, however, it still
> failed with the same error.
>
> netshinterface ipv4 set address IP_ADAPTER_INFO.AdapterName static
> 10.6.36.159 255.255.0.0 10.6.0.1 1
>
> I think that "netshinterface ip" is same as "netshinterface ipv4"
> i.e. The default is always ipv4.
>
> However, I noticed one interesting thing. Onvista, one can specify
> interface name OR interface index to "netshinterface ip set address"
> command. So when I used following command, it worked.
>
> netshinterface 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?
>
> --
> Kerry Brown
> Microsoft MVP - Shell/Userhttp://www.vistahelp.ca/phpBB2/- Hide quoted text -
>
> - Show quoted text -


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

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Configuring web certificate for ssl using netsh on vista rc2 codedurenard Windows Vista Security 2 10-15-2009 12:16 PM
netsh to set IP address on vista.. pdabak@yahoo.com Windows Vista Networking 0 02-10-2008 04:26 PM
Vista Exceptions & netsh firewall output Gayle Windows Vista Security 0 08-02-2007 03:38 AM
NETSH int ip reset on vista ultimate Bernard Windows Vista General Discussion 0 02-11-2007 06:14 AM
Netsh in Vista Michael Henderson Windows Vista Networking 1 12-14-2006 03:48 AM



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59