@echo off
setlocal

:: Create file with systen info using date
set "filename=system_information_%date:/=-%.txt"

:: Replaces teh spaces with underscores in the file name
set "filename=%filename: =_%"

:: Display to user their report is being created
echo Creating Sytem Information Report into txt file

:: Write heading to the report file
echo Sytem Infomration > "%filename%"

:: Add spacing and the systems OS information to the report file
echo. >> "%filename%"
echo OS: >> "%filename%"
ver >> "%filename%"
echo. >> "%filename%"
echo. >> "%filename%"

:: Retrive CPU name with WMIC and write use the first result 
echo CPU: >> "%filename%"
echo. >> "%filename%"
for /f "skip=1 tokens=*" %%c in ('wmic cpu get name') do (
	echo %%c >> "%filename%"
	goto :break
)
:break
echo. >> "%filename%"
echo. >> "%filename%"

:: Retrieve RAM capacity from WMIC without headers
echo RAM: >> "%filename%"
echo. >> "%filename%"
wmic memorychip get capacity | findstr /r "[0-9]" >> "%filename%"
echo. >> "%filename%"
echo. >> "%filename%"

:: Retrieve free space on the C drive
echo Disk Drives (GB) >> "%filename%"
wmic logicaldisk where "DeviceID='C:'" get FreeSpace >> "%filename%"

echo. >> "%filename%"
echo. >> "%filename%"

:: Retrieve IPv4 address and place in report file
ipconfig | find "IPv4 Address" >> "%filename%"

echo. >> "%filename%"

::Display to user their report is complete 
echo Your system infomration report has been generated >> "%filename%"

:: Wait for user to read and to press ENTER
pause