How to get LAN and WLAN MAC Address with batchfile?

579 Views Asked by At

I've recently been trying to make a batch file that will identify the serial number, WLAN & LAN MAC Address of the of the computer. After retrieving set info, I would like it to rename the computer description in this format: "Serial Number 4444 WLAN 4444 LAN 4444"

The code for the wlan and lan mac address doesn't work and I can't to figure out why.

I tried doing it in powershell and I was successful but I didn't know how to call the variable.

$var=(Get-WmiObject Win32_NetworkAdapterConfiguration | where {$_.ipenabled -EQ $true}).Macaddress | select-object -first 1

#!/bin/bash

#Change Name
wmic computersystem where "name='%computername%'" call rename name=Computer2

#Get Serial Number
for /f %%i in ('wmic bios get serialnumber ^|find "M"') do set cereal=%%i
#Get WLAN MAC Address
for /f "usebackq tokens=3 delims=," %%b in ('getmac /fo csv /v ^| find "Wi-Fi"') do set WLAN=%%~b

#Get LAN MAC Address
for /f "usebackq tokens=3 delims=," %%a in ('getmac /fo csv /v ^| find "Ethernet"') do set LAN=%%~a
#Set the Computer Description Name
set ComputerDes=%cereal% WLAN %WLAN% LAN %LAN%
net config server /srvcomment:"%ComputerDes%"

#Restart the PC
shutdown.exe /r /t 60
0

There are 0 best solutions below