Re: vbs script
- From: "Dave \"Crash\" Dummy" <invalid@xxxxxxxxxxxxxxx>
- Date: Wed, 27 Jul 2011 11:38:27 -0400
Steve Wolf wrote:
Can anyone give me the complete script to get the mac address of the current nic card or cards in the computer. Im not a programer, but i have a little vbs script that we use to print basic info about the computer and then we print it off and paste to the computer. I want the mac address, but every script I see on the net seems to give me more info than I need eg.
RAS Async Adapter mac addresses (there apper to be 3 of those mac addresses.) I just want the macs for the Nic's
The information you want is easily available with the included ipconfig
utility. It is just a matter of sifting out what you want. I threw
together the script below to extract the adapter description and MAC
number and print them to a file. I only have one Ethernet adapter, so I
couldn't test it on a system with multiple adapters. I can't guarantee
it will work, but I can guarantee it won't hurt anything. :-)
This is what the output on my computer looks like (without the line wrap):
Description . . . . . . . . . . . : Marvell Yukon 88E8053 PCI-E Gigabit
Ethernet Controller
Physical Address. . . . . . . . . : 00-01-29-A5-F1-41
The output could be fancied up with a little extra coding, but I wanted
to keep it simple. That is also why I use the same file (NicData.txt) to
hold the raw data and the filtered output.
;=====================NetAdapters.vbs===================
Set WshShell=CreateObject("Wscript.Shell")
ret=WshShell.run("cmd /c ipconfig /all > NicData.txt",0,1)
Set fso=CreateObject("Scripting.FileSystemObject")
Set input=fso.OpenTextFile("NicData.txt")
dim data
do until input.AtEndOfStream
line=input.readLine
if instr(line,"Ethernet adapter") then call getData
loop
input.close
Set output=fso.CreateTextFile("NicData.txt")
output.write data
output.close
sub getData()
do
line=trim(input.readLine)
if instr(line,"Description") then
data=data & line & vbCRLF
end if
if instr(line,"Physical Address") then
data=data & line & vbCRLF
exit sub
end if
loop
end sub
;====================================================
--
Crash
"The future ain't what it used to be."
~ Yogi Berra ~
.
- Follow-Ups:
- Re: vbs script
- From: Steve Wolf
- Re: vbs script
- From: Adam Sandler
- Re: vbs script
- References:
- vbs script
- From: Steve Wolf
- vbs script
- Prev by Date: vbs script
- Next by Date: Re: vbs script
- Previous by thread: vbs script
- Next by thread: Re: vbs script
- Index(es):
Relevant Pages
|