Jump to content

[Question] - Get MAC into variable in batchfile


Doc Symbiosis

Recommended Posts

Hi there,

In a batchfile, I need to get the MAC-address of "Local Area Connection" into a variable, but still can't figure out how.

There aren't any adequate parameters for the getmac and ipconfig command. Thought about using the find command, but there's a problem, when more than one network adapter is installed. How do I get the one of "Local Area Connection"

Does anyone have an idea?

Thanks in advance

Title Edited - Please follow new posting rules from now on.

--Zxian

Link to comment
Share on other sites


well ipconfig /all will display the mac address, but you would have to search through it..

or theres a tool from Microsoft called getmac.exe you would have to download and run their installer, but then you could just put getmac32.exe into your $$\system32\ folder and it'd be included every time you use your unattended xpcd (if you use one at all)

http://www.microsoft.com/windows2000/techi...ng/getmac-o.asp

Output of the tool:

gdfgdfgdfgdfg5fh.jpg

1st MAC is loopback

2nd MAC is my Ethernet card

3rd MAC is my VMWare Ethernet card

marked everything out in red cause i have no idea what MAC addresses says (vendor model etc..) or what the GUID may say about the system... can never be too paranoid :P

hope this helps.

Link to comment
Share on other sites

Systeminfo

will say which NIC is Local Area Connection. That's the only command that I find will say that, even

wmic nic list

(and other wmic parameters) won't. Perhaps you could use both.

(Getmac is already available in XP).

Edited by Takeshi
Link to comment
Share on other sites

wow lol. i don't even remeber posting that last night i was so tired.. reading it now and i have no idea why i mentioned getmac in my post since you had mentioned it in your post..

anyways.. for anyone that may still want this..

you'll have to have getmac (comes default with windows... mine didn't come with it for some reason... stupid emachines..)

FOR /F %%A IN ('getmac') DO SET MAC=%%A

and that will set the bottom most mac address to %MAC%

works great for systems with only 1 network card. I could probably go further and have it validate against the nbtstat -a ipaddresshere to get the "true" MAC.. but i'm getting tired..and i'm sure we all don't want another stupid reply by me :P

Edited by Bi0haZarD
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...