I have added YOUR-COMMAND | Out-File -FilePath c:\PATH\TO\FOLDER\OUTPUT.txt
after each command but still, no file was created with the pc specs. After saving the script in the batch file, the cmd is popping up and the specs are being shown, but I need to have it automatically saved on the desktop.
@echo off
echo Checking your system info, Please wait...
ipconfig | find /i "IPv4"
systeminfo | findstr /c:"Host Name"
systeminfo | findstr /c:"OS Name"
systeminfo | findstr /c:"System type"
systeminfo | findstr /c:"Domain"
systeminfo | findstr /c:"OS Version"
systeminfo | findstr /c:"System Model"
systeminfo | findstr /c:"Total Physical Memory"
systeminfo | findstr /c:"System Manufacturer"
echo.
echo Service Tag:
wmic bios get serialnumber
echo.
echo Hard Drive Space:
wmic diskdrive get Name, Manufacturer, Model, InterfaceType, MediaType, SerialNumber, size
echo.
echo CPU:
wmic cpu list brief
echo.
echo Memory:
wmic MemoryChip get BankLabel, Capacity, MemoryType, TypeDetail, Speed
echo.
echo BaseBoard:
wmic baseboard get product,Manufacturer,version,serialnumber
pause
As per Compo's advice, a much more efficient approach is to enact multiple findstr commands on a singular instance of Systeminfo. The below uses a macro to enact and format the output of successful findstr commands, with each string to be found supplied to the macro via substring modification. The
For /F
loop that runs the system info command is wrapped in parentheses to enable redirection to the .txt file of the full command output rather than performing multiiple write actions.The same approach regarding macro usage can be applied to the wmic commands.