The following code could be used to write everything into a file and display also in the console window:
@echo off
setlocal EnableExtensions DisableDelayedExpansion
title %~n0
if not "%~1" == "max" start /MAX %SystemRoot%\System32\cmd.exe /D /C %0 max & exit /B
set "RecordFile=%UserProfile%\%ComputerName%.txt"
del "%RecordFile%" 2>nul
set "TempFile=%TEMP%\%~n0.tmp"
call :OutputInfo "Hard Disk Info"
call :OutputData %SystemRoot%\System32\WindowsPowerShell\v1.0\powershell.exe "Get-PhysicalDisk"
call :OutputInfo "CPU Info"
call :OutputData %SystemRoot%\System32\wbem\wmic.exe CPU GET Caption,Name
call :OutputInfo "RAM Info"
call :OutputData %SystemRoot%\System32\wbem\wmic.exe MEMORYCHIP GET Capacity,MemoryType,Speed,TypeDetail,Manufacturer
call :OutputInfo "Windows Version"
call :OutputData %SystemRoot%\System32\cmd.exe /D /S /C "%SystemRoot%\System32\systeminfo.exe 2>nul | %SystemRoot%\System32\findstr.exe /B /I /C:"OS Name" /C:"OS Version" /C:"System Type" /C:"System Locale" /C:"Input Locale""
call :OutputInfo "Microsoft Office Version"
echo LCID 1033 = English (US)>>"%RecordFile%"
echo LCID 1033 = English (US)
call :OutputData %SystemRoot%\System32\wbem\wmic.exe PRODUCT where "Name like '%%%%Microsoft Office%%%%'" GET Language,Name,Version
del "%TempFile%" 2>nul
echo(
pause
exit /B
:OutputData
%* >"%TempFile%"
for %%I in ("%TempFile%") do if %%~zI == 0 goto :EOF
type "%TempFile%">>"%RecordFile%"
type "%TempFile%"
goto :EOF
:OutputInfo
if not exist "%RecordFile%" goto InfoOutput
(echo =================================& echo()>>"%RecordFile%"
echo =================================
echo(
:InfoOutput
(echo %~1&echo()>>"%RecordFile%"
echo %~1
echo(
goto :EOF
Note 1:
The PowerShell command line outputs on Windows 7 with by default installed PowerShell 2.0 just the following error message because of the cmdlet Get-PhysicalDisk is not available with PowerShell 2.0.
The term 'Get-PhysicalDisk' is not recognized as the name of a cmdlet, function,
script file, or operable program. Check the spelling of the name, or if a path
was included, verify that the path is correct and try again.
At line:1 char:17
+ Get-PhysicalDisk <<<<
+ CategoryInfo : ObjectNotFound: (Get-PhysicalDisk:String) [], Co
mmandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
Note 2:
WMIC outputs data always Unicode encoded using UTF-16 Little Endian (two or four bytes per character) with byte order mark (BOM) while PowerShell and SystemInfo output data with just one byte per character. For that reason it is not advisable to directly output all data into one text file because of that would result in a text file using more than one character encoding making the file unreadable. Therefore each data output is first written into a temporary file always created new. The temporary file content is output next with command TYPE and the one byte per character encoded output is appended to the record file.
Note 3:
It is necessary to escape both %
around Microsoft Office
with three additional percent signs to pass %Microsoft Office%
to wmic.exe
executed in subroutine OutputData
. Each %
must be escaped with one more %
to be interpreted as literal character in a batch file. But a command line with CALL is processed a second time by the Windows command processor. Therefore two more percent signs are necessary on both sides to get first %%Microsoft Office%%
after first parsing of the command line and next %Microsoft Office%
after the second parsing caused by command CALL.
Note 4:
The usage of just %Office%
instead of %Microsoft Office%
could result in output not really wanted like:
0 Microsoft Visual Studio 2010 Tools for Office Runtime (x64) 10.0.50908
To understand the commands used and how they work, open a command prompt window, execute there the following commands, and read the displayed help pages for each command, entirely and carefully.
call /?
cmd /?
del /?
echo /?
exit /?
for /?
goto /?
if /?
pause /?
powershell get-help get-physicaldisk
set /?
start /?
systeminfo /?
title /?
type /?
wmic /?
wmic cpu /?
wmic cpu get /?
and Win32_Processor class
wmic memorychip /?
wmic memorychip get /?
and Win32_PhysicalMemory class
wmic product /?
wmic product get /?
and Win32_Product class
See also: