Batch for Mac And Computer name to a file

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
creyes3
Posts: 2
Joined: 28 May 2015 10:12

Batch for Mac And Computer name to a file

#1 Post by creyes3 » 28 May 2015 10:27

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

foxidrive
Expert
Posts: 6031
Joined: 10 Feb 2012 02:20

Re: Batch for Mac And Computer name to a file

#2 Post by foxidrive » 30 May 2015 01:27

Please show us an example of what you want.

creyes3
Posts: 2
Joined: 28 May 2015 10:12

Re: Batch for Mac And Computer name to a file

#3 Post by creyes3 » 02 Jun 2015 04:59

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

foxidrive
Expert
Posts: 6031
Joined: 10 Feb 2012 02:20

Re: Batch for Mac And Computer name to a file

#4 Post by foxidrive » 02 Jun 2015 20:08

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.

Dos_Probie
Posts: 233
Joined: 21 Nov 2010 08:07
Location: At My Computer

Re: Batch for Mac And Computer name to a file

#5 Post by Dos_Probie » 06 Jun 2015 04:19

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%


Post Reply