Page 1 of 1

Batch for Mac And Computer name to a file

Posted: 28 May 2015 10:27
by creyes3
Very novice on this but how i can combine this 2 lines so writes to a file beside each other

FINDSTR "^%computername%$" < C:\scripts\macadd\log.txt >NUL || ECHO %computername%>>C:\scripts\macadd\log.txt

wmic nicconfig where "ipenabled='true'" get macaddress



thanks in advance

Re: Batch for Mac And Computer name to a file

Posted: 30 May 2015 01:27
by foxidrive
Please show us an example of what you want.

Re: Batch for Mac And Computer name to a file

Posted: 02 Jun 2015 04:59
by creyes3
i want the text file to have

computername macaddress

but i will prefer if possible to be write to excel file but if not to a text file will ok for now

Thanks once more

Re: Batch for Mac And Computer name to a file

Posted: 02 Jun 2015 20:08
by foxidrive
One way is to use two statements and get the item you need into a different environment variable in each line.
Those two environment variables can then be echoed into a file on the same line.

Re: Batch for Mac And Computer name to a file

Posted: 06 Jun 2015 04:19
by Dos_Probie
creyes3 wrote:i want the text file to have

computername macaddress

but i will prefer if possible to be write to excel file but if not to a text file will ok for now

Thanks once more


Late to the party and you did not say if you wanted the mac of your lan or wireless adapter but here is a simple example.
~DP

Code: Select all

@Echo Off

Set Output=%systemdrive%\macadd\log.txt

:: ### COMPUTER NAME:
FOR /F "Tokens=2 Delims==\" %%C In ('WMIc OS Get csname /Value') Do Set CompName=%%C
:: ### MAC ADDRESS OF LAN ADAPTER:
For /F "Tokens=* Skip=1" %%M In ('"WMIc Nicconfig Where IPEnabled=True Get macaddress|FindStr ."') Do Set "MacAddy=%%M"

:: ### OUTPUT:
Echo. Computer Name and Mac Physical Address: %CompName% %MacAddy% >>%Output%