-
Reading MAC w/ VBS
I'm writing a vb script to extract the MAC from a workstation and write it as the computer name. I have a working solution now but it's a bit clumsy.
I have a batch file that calls "getmac /fo table /nh >> c:\mac.txt", then calls a vb script file which reads the MAC address from the file, writes the name then restarts the computer.
I'm sure there must be an easier way to get the MAC, avoid using the text file and have a complete solution with just vbs. I haven't been able to find the MAC in the registry, but I know it's possible (though I don't know how exactly) to read the MAC using Windows Management Instrumentation (WMI).
So, I was hoping someone could help we out with some vbs code to write the MAC into a variable. From there I should be able to get it going. I'll give the rest of the script, small as it is, to anyone who can help me out.
Thanks.
-
I found a Java program that will do it, but through parsing ifconfig (Unix) or ipconfig (Windows) output. It's a little cleaner than using an intermediate text file. Link: http://forum.java.sun.com/thread.jsp...711&tstart=225
Googling for this kind of thing is touch because of the 'mac' phrase!
-
Thanks Rock. I'd still like to keep everything in one vbs though. That windows sections of code will be longer than the whole rest of my script. Any ideas on how to do it with vbs?
-
Parsing the output of "ipconfig /all" would still seem to be the key. I don't know enough about vbs to know if you can capture that output into a string and then run through it programmatically.