Jump to content

Recommended Posts

Posted

dos command line

 

echo %machinename% %time% >> blah.txt

 

Ive got it at the minute just dumping the entire ipconfig /all output to a file, but wouldnt mind just the mac address

 

Is there a way to do it with the net sh command?

  • 7 months later...
Posted

Giving an old thread a bump.

 

I've used getmac to output to a text file.

Here's the command I used:

getmac /FO CSV /NH>c:\%computername%.txt

 

and here's the output:

"40-61-86-07-16-00","\Device\Tcpip_{8677B475-2070-4AFE-8EFD-D8ABE83A3C17}"

"08-00-27-00-04-C3","\Device\Tcpip_{B6BA71F4-66D0-4965-AFCE-FD065B7129AB}"

 

What command do I use to add the computer name to the end of the output? e.g.

"40-61-86-07-16-00","\Device\Tcpip_{8677B475-2070-4AFE-8EFD-D8ABE83A3C17}","mypc"

"08-00-27-00-04-C3","\Device\Tcpip_{B6BA71F4-66D0-4965-AFCE-FD065B7129AB}","mypc"

 

Thanks

Posted

@ECHO OFF
SETLOCAL ENABLEDELAYEDEXPANSION

getmac /FO CSV /NH>c:\%computername%temp.txt

SET name=%computername%

REM Line count required
SET LineCount=0

REM Read from file. value  will read 2 lines
FOR /F "tokens=*" %%A IN ('TYPE "c:\%computername%temp.TXT" 2^>NUL') DO (
SET /A LineCount+=1
rem ECHO Read "%%A" with a LineCount of !LineCount!
SET Value!LineCount!=%%A
IF /I !LineCount! EQU 2 GOTO DoneReading
)

:DoneReading
ECHO %Value1%,"%name%" > c:\%computername%.txt
ECHO %Value2%,"%name%" >> c:\%computername%.txt

REM Tidy dummy file
DEL c:\%computername%temp.txt

 

should do what you want.

 

BoX

  • Thanks 2
Posted
All the years I've been doing ipconfig /all and trawling back up through the millions of extra adapters Vista etc spit out, can't believe I never knew about getmac. Cheers all :)

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now



×
×
  • Create New...