Set MAC Address as Computer Description .BAT

May 19, 2011 at 07:07:29
Specs: Windows 7
I am trying to write a .bat file that will get the mac address and make it the computer description. So far I have tried using a variable to capture the command getmac (set mac=getmac) as a variable and then use the command (net config server /srvcomment:%mac%) but it then sets the computer description as getmac. However, if I export the (set mac=getmac > mac.txt) the mac.txt file includes the MAC address that I want to put in the computer description. Also i'm getting a similar response like:

Physical Address Transport Name
=================== ==========================================================
B8-AC-6F-21-44-14 \Device\Tcpip_{E5FB4E75-B59E-488F-93E9-7DBE4F5694D2}

I've also tried using this forum to figure something out, but i'm stuck...

and I would like to somehow just get B8-AC-6F-21-44-14 and set it as the computer description. If anyone can pull this off.... THEY ARE THE MAN TO ME! lol thanks!

See More: Set MAC Address as Computer Description .BAT

Report •

May 22, 2011 at 10:54:58
Untested VBScript, because I'm at work:
For Each net In GetObject("winmgmts:").ExecQuery( _
    "SELECT * FROM Win32_NetworkAdapter " & _
    "WHERE AdapterTypeID = 0 AND NetConnectionStatus = 2")
  CreateObject("WScript.Shell").RegWrite _
    "HKLM\System\CurrentControlSet\Services\lanmanserver\parameters\srvcomment", _
    net.MACAddress, "REG_SZ"
  Exit For
Next 'net

Sets the Computer Description to the MAC address of the first connected Ethernet adapter. If none are found, the script does nothing. You'll probably need to reboot to see a change.

How To Ask Questions The Smart Way

Report •

May 22, 2011 at 16:08:46
@REM Get the MAC (if more than one, we'll output the last one) NB
@setlocal enableextensions
@echo off

ipconfig/all | findstr ^ /C:"Physical Address" ^ > MYMACS

for /F "delims=" %%a in (MYMACS) do call :PROC "%%a"
echo %MACA%
goto :EOF

set a=%1
set a=%a: =%
set a=%a:.=%
set MACA=%a:PhysicalAddress:=%
set MACA=%MACA:"=%

Report •

May 23, 2011 at 07:54:54
@NB2011 - Thanks for the response. It set the computer name to Physical Address Transport Name
and nothing else. A lot closer than I was! I appreciate your time and efforts!

@Razor2.3 - Thank you for your response as well. I have not tried the VB Script yet

Report •
Related Solutions

Ask Question