try:
Code:
@echo off
::------------------------
:: Global Variables
::------------------------
setlocal enabledelayedexpansion
set lineA = 1
set lineB = 1
set lineC = 1
set computername = hostname
set date = date /t
set time = time /t
set stringcat=name
set stringcat=%stringcat%,User Name
set stringcat=%stringcat%,Device Name
set stringcat=%stringcat%,Serial Number
set stringcat=%stringcat%,Computer Model
set stringcat=%stringcat%,Deploy Date
set stringval=%name%
::------------------------
:: User Name
::------------------------
set stringval=%stringval%,%username%
echo Username,%username% >> earthtabletsjamesTest.csv
::------------------------
:: Device Name
::------------------------
set stringval=%stringval%,%computername%
echo Computer Name,%computername% >> earthtabletsjamesTest.csv
::------------------------
:: Get Serial Number
::------------------------
for /f "delims=" %%A in ('wmic bios get serialnumber') do (
if !lineA! equ 2 set serialNumber=%%A
set /a lineA+=1)
set stringval=%stringval%,%serialNumber%
echo Serial Number,%serialNumber% >> earthtabletsjamesTest.csv
::------------------------
:: Get Model
::------------------------
for /f "delims=" %%A in ('wmic csproduct get name') do (
if !lineB! equ 2 set modelName=%%A
set /a lineB+=1)
set stringval=%stringval%,%modelName%
echo Computer Model,%modelName% >> earthtabletsjamesTest.csv
::------------------------
:: Deploy Date
::------------------------
set stringval=%stringval%,%date% %time%
echo Deploy Date,%date% %time% >> earthtabletsjamesTest.csv
::------------------------
:: Get Mac Address
::------------------------
for /f "delims=" %%A in ('ipconfig/all ^| find "Physical Address"') do (
for /f "tokens=2-7 delims=:-" %%B in ("%%A") do (
if "%%C" NEQ "00" (
set macadress=%%B-%%C-%%D-%%E-%%F-%%G
call :test
)
)
)
echo %stringcat%>>c:test2.csv
echo %stringval%>>c:test2.csv
pause
:test
echo Mac Addresses,%macadress% >> earthtabletsjamesTest.csv
set stringcat=%stringcat%,Wired Mac Address
set stringval=%stringval%,%macadress%
its not perfect but if statements that set variables are special...
EDIT: found this, at the bottom http://www.cynosurex.com/Forums/Disp..._in_Batch_File
I dont have time to try it out yet...