Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > VB Script

Vista - IP to mac address

Reply
 
Old 01-14-2009   #1 (permalink)
freddy


 
 

IP to mac address

I have a script that get the ip from a computer. The problem is that sice I
have vmware installed on some of the computer it gives me more than one ip
address. So since the phyical ip address for the machine start with a 10. I
have it in the script to look at the first number ---which works fine. My
question is how to get the mac address of the 10.x.x.x ip address and not
the rest.

Here is the script.
strcomputer = "."
'******************************************* Get IP Address
***********************************************
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set IPConfigSet = objWMIService.ExecQuery _
("Select * from Win32_NetworkAdapterConfiguration Where IPEnabled = True")
Set objNetwork = CreateObject("Wscript.Network")
For Each IPConfig In IPConfigSet
strIPAddress = IPConfig.IPAddress(0)
arrIPAddress = Split(strIPAddress, ".")
If arrIPAddress(0) = "10" Then
wscript.echo IPConfig.IPAddress(0)
'objExcel.Cells(x, 7).Value = IPConfig.IPAddress(0)
Else
End If
Next

Thanks

My System SpecsSystem Spec
Old 01-14-2009   #2 (permalink)
Pegasus \(MVP\)


 
 

Re: IP to mac address


"freddy" <freddy@xxxxxx> wrote in message
news:1A4B9E9A-7E1A-4577-877A-4E63D039E021@xxxxxx
Quote:

>I have a script that get the ip from a computer. The problem is that sice I
> have vmware installed on some of the computer it gives me more than one ip
> address. So since the phyical ip address for the machine start with a 10.
> I
> have it in the script to look at the first number ---which works fine. My
> question is how to get the mac address of the 10.x.x.x ip address and
> not
> the rest.
>
> Here is the script.
> strcomputer = "."
> '******************************************* Get IP Address
> ***********************************************
> Set objWMIService = GetObject("winmgmts:" _
> & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
> Set IPConfigSet = objWMIService.ExecQuery _
> ("Select * from Win32_NetworkAdapterConfiguration Where IPEnabled = True")
> Set objNetwork = CreateObject("Wscript.Network")
> For Each IPConfig In IPConfigSet
> strIPAddress = IPConfig.IPAddress(0)
> arrIPAddress = Split(strIPAddress, ".")
> If arrIPAddress(0) = "10" Then
> wscript.echo IPConfig.IPAddress(0)
> 'objExcel.Cells(x, 7).Value = IPConfig.IPAddress(0)
> Else
> End If
> Next
>
> Thanks
Change
WScript.echo IPConfig.IPAddress(0)
to
WScript.echo IPConfig.IPAddress(0) & " " & IPConfig.macaddress


My System SpecsSystem Spec
Old 04-04-2009   #3 (permalink)
gg


 
 

Re: IP to mac address

just out of curiosity, I tried it and I got 2 identical lines of output even
thought on my xp pc I got only one NIC present.


when I run it on a virtual w2k pc I just get one line as expected

what could have happened to the the "strange" xp?

"Pegasus (MVP)" wrote:
Quote:

>
> "freddy" <freddy@xxxxxx> wrote in message
> news:1A4B9E9A-7E1A-4577-877A-4E63D039E021@xxxxxx
Quote:

> >I have a script that get the ip from a computer. The problem is that sice I
> > have vmware installed on some of the computer it gives me more than one ip
> > address. So since the phyical ip address for the machine start with a 10.
> > I
> > have it in the script to look at the first number ---which works fine. My
> > question is how to get the mac address of the 10.x.x.x ip address and
> > not
> > the rest.
> >
> > Here is the script.
> > strcomputer = "."
> > '******************************************* Get IP Address
> > ***********************************************
> > Set objWMIService = GetObject("winmgmts:" _
> > & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
> > Set IPConfigSet = objWMIService.ExecQuery _
> > ("Select * from Win32_NetworkAdapterConfiguration Where IPEnabled = True")
> > Set objNetwork = CreateObject("Wscript.Network")
> > For Each IPConfig In IPConfigSet
> > strIPAddress = IPConfig.IPAddress(0)
> > arrIPAddress = Split(strIPAddress, ".")
> > If arrIPAddress(0) = "10" Then
> > wscript.echo IPConfig.IPAddress(0)
> > 'objExcel.Cells(x, 7).Value = IPConfig.IPAddress(0)
> > Else
> > End If
> > Next
> >
> > Thanks
>
> Change
> WScript.echo IPConfig.IPAddress(0)
> to
> WScript.echo IPConfig.IPAddress(0) & " " & IPConfig.macaddress
>
>
>
My System SpecsSystem Spec
Reply

Thread Tools


Similar Threads
Thread Forum
How to eliminate invalid e-mail address from address book Vista mail
Can i migrate/associate http://mynick.spaces.live.com/ web address with my new email address??? Live Messenger
setting for replies: receiver address - not default address Vista mail
Help me --Hyper link address.. doesnt take me.. to article (web address) in Window Vista 32 Vista General


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

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