@echo off REM ############################################# REM Description: This script is used to get system information. REM NOTE: https://www.cygwin.com/, http://cmdlinecalc.sourceforge.net/ REM Required files: sed, cut, gawk, uniq, sort, wc, grep, cmdlinecalc, head REM ############################################# REM ######################### REM Set variables REM ######################### set PATH=%PATH%;C:\"Program Files"\"System Utilities"\bin\ set cmdlinecalc="C:\Program Files (x86)\System Utilities\bin\cmdlinecalc.exe" REM ######################### REM This is the main part of the script. REM ######################### :main if [%1]==[] goto :usage goto :%~1 2>nul :usage REM This displays the usage options. echo usage: %0 [option] echo. echo name Displays system name echo os Displays operating system echo osfull Displays operating system (full details) echo osshort Displays operating system (short) echo tag Displays chassis tag number echo hardwarefull Displays hardware (full details) echo chassis Displays chassis echo model Displays model goto :exit REM ######################### REM This displays the system name. REM ######################### :name for /f "tokens=*" %%x in ('wmic computersystem get Name /value ^| find "Name=" ^| sed "s/\s*$//g" ^| cut -d "=" -f 2-') do (set name=%%x) for /f "tokens=*" %%x in ('wmic computersystem get Domain /value ^| find "Domain=" ^| sed "s/\s*$//g" ^| cut -d "=" -f 2-') do (set domain=%%x) for /f "tokens=*" %%x in ("%name%.%domain%") do (set value=%%x) echo %value% goto :exit REM ######################### REM This displays the operating system. REM ######################### :os for /f "tokens=*" %%x in ('wmic os get Caption /value ^| find "Caption=" ^| sed "s/\s*$//g" ^| cut -d "=" -f 2-') do (set value=%%x) echo %value% goto :exit REM ######################### REM This displays the operating system (full details). REM ######################### :osfull for /f "tokens=*" %%x in ('wmic os get Caption /value ^| find "Caption=" ^| sed "s/\s*$//g" ^| cut -d "=" -f 2-') do (set os_name=%%x) for /f "tokens=*" %%x in ('wmic os get ServicePackMajorVersion /value ^| find "ServicePackMajorVersion=" ^| sed "s/\s*$//g" ^| cut -d "=" -f 2-') do (set service_pack=%%x) for /f "tokens=*" %%x in ("SP%service_pack%") do (set os_version=%%x) for /f "tokens=*" %%x in ('wmic os get OSArchitecture /value ^| find "OSArchitecture=" ^| sed "s/\s*$//g" ^| cut -d "=" -f 2- ^| cut -d "-" -f 1') do (set arch=%%x) for /f "tokens=*" %%x in ("%arch%-bit") do (set arch=%%x) for /f "tokens=*" %%x in ('wmic computersystem get SystemType /value ^| find "SystemType=" ^| sed "s/\s*$//g" ^| cut -d "=" -f 2- ^| cut -d "-" -f 1') do (set os_arch=%%x) if "%os_version%" == "SP0" goto :no_service_pack for /f "tokens=*" %%x in ("%os_name% %os_version% (%arch% %os_arch%^)") do (set value=%%x) echo %value% goto :exit :no_service_pack for /f "tokens=*" %%x in ("%os_name% (%arch% %os_arch%^)") do (set value=%%x) echo %value% goto :exit REM ######################### REM This displays the operating system (short). REM ######################### :osshort for /f "tokens=*" %%x in ('wmic os get Caption /value ^| find "Caption=" ^| sed "s/\s*$//g" ^| cut -d "=" -f 2- ^| gawk "{print $1,$2}"') do (set value=%%x) echo %value% goto :exit REM ######################### REM This displays chassis tag number. REM ######################### :tag for /f "tokens=*" %%x in ('wmic csproduct get Vendor /value ^| find "Vendor=" ^| sed "s/\s*$//g" ^| cut -d "=" -f 2-') do (set manufacturer=%%x) echo %manufacturer% | grep -Ei "(Microsoft|VMware)" > nul 2>&1 if %errorlevel% equ 0 goto :tag_virtual for /f "tokens=*" %%x in ('wmic csproduct get IdentifyingNumber /value ^| find "IdentifyingNumber=" ^| sed "s/\s*$//g" ^| cut -d "=" -f 2-') do (set value=%%x) echo %value% goto :exit :tag_virtual for /f "tokens=*" %%x in ("Virtual") do (set value=%%x) echo %value% goto :exit REM ######################### REM This displays the hardware (full details). REM ######################### :hardwarefull for /f "tokens=*" %%x in ('wmic cpu get Name /value ^| find "Name=" ^| sed "s/\s*$//g" ^| uniq ^| cut -d "=" -f 2-') do (set cpu_model=%%x) for /f "tokens=*" %%x in ('wmic cpu get DeviceID /value ^| find "DeviceID=" ^| sed "s/\s*$//g" ^| sort ^| uniq ^| wc -l') do (set physical_cpus=%%x) goto :find_cores_per_cpu :find_cores_per_cpu set failures=0 wmic cpu get /value | find "NumberOfCores=" > nul 2>&1 if %errorlevel% equ 0 goto :find_cores_per_cpu_available set cores_per_cpu=NA if %cores_per_cpu% equ NA set /a failures=%failures% + 1 goto :find_threads_per_cpu :find_cores_per_cpu_available for /f "tokens=*" %%x in ('wmic cpu get NumberOfCores /value ^| find "NumberOfCores=" ^| sed "s/\s*$//g" ^| uniq ^| cut -d "=" -f 2-') do (set cores_per_cpu=%%x) goto :find_threads_per_cpu :find_threads_per_cpu wmic cpu get /value | find "NumberOfLogicalProcessors=" > nul 2>&1 if %errorlevel% equ 0 goto :find_threads_per_cpu_available set threads_per_cpu=NA if %threads_per_cpu% equ NA set /a failures=%failures% + 1 set hyper_threading=NA set logical_cpus=NA goto :cpu_summary :find_threads_per_cpu_available for /f "tokens=*" %%x in ('wmic cpu get NumberOfLogicalProcessors /value ^| find "NumberOfLogicalProcessors=" ^| sed "s/\s*$//g" ^| uniq ^| cut -d "=" -f 2-') do (set threads_per_cpu=%%x) goto :find_hyper_threading :find_hyper_threading if %threads_per_cpu% gtr %cores_per_cpu% goto :find_hyper_threading_available set hyper_threading=No goto :find_logical_cpus :find_hyper_threading_available set hyper_threading=Yes goto :find_logical_cpus :find_logical_cpus set /a logical_cpus=%physical_cpus% * %threads_per_cpu% goto :cpu_summary :cpu_summary if %failures% gtr 0 goto :wmi_patch_needed for /f "tokens=*" %%x in ("CPU: Model: %cpu_model%, Hyper-Threading: %hyper_threading%, Physical CPU's: %physical_cpus%, Cores per CPU: %cores_per_cpu%, Threads per CPU: %threads_per_cpu%, Logical CPU's: %logical_cpus%") do (set cpu_value=%%x) goto :find_ram_total :wmi_patch_needed for /f "tokens=*" %%x in ("CPU: NOTE: Hotfix needed for WMI for CPU information, Windows XP - http://support.microsoft.com/kb/936235/, Windows 2003 - http://support.microsoft.com/kb/932370/") do (set cpu_value=%%x) goto :find_ram_total :find_ram_total for /f "tokens=*" %%x in ('wmic memorychip get DataWidth /value ^| find "DataWidth=" ^| sed "s/\s*$//g" ^| cut -d "=" -f 2-') do (set ram_data_width=%%x) for /f "tokens=*" %%x in ('wmic memorychip get /value ^| sed -n "/^Capacity=/,/^DataWidth="%ram_data_width%"/p" ^| find "Capacity=" ^| sed "s/\s*$//g" ^| cut -d "=" -f 2 ^| gawk "{s+=$1} END {print s}"') do (set ram_total=%%x) if %ram_total% lss 1024 goto :find_low_ram goto :find_high_ram :find_low_ram for /f "tokens=*" %%x in ('%cmdlinecalc% %ram_total% / 1024 / 1024') do (set ram_total_mb=%%x) for /f "tokens=*" %%x in ("%ram_total_mb% MB") do (set ram_total_pretty=%%x) goto :ram_modules_installed :find_high_ram for /f "tokens=*" %%x in ('%cmdlinecalc% %ram_total% / 1024 / 1024 / 1024') do (set ram_total_gb=%%x) for /f "tokens=*" %%x in ("%ram_total_gb% GB") do (set ram_total_pretty=%%x) goto :find_ram_modules_installed :find_ram_modules_installed for /f "tokens=*" %%x in ('wmic csproduct get Vendor /value ^| find "Vendor=" ^| sed "s/\s*$//g" ^| cut -d "=" -f 2-') do (set manufacturer=%%x) echo %manufacturer% | grep -Ei "(Microsoft|VMware)" > nul 2>&1 if %errorlevel% equ 0 goto :ram_virtual for /f "tokens=*" %%x in ('wmic memorychip get /value ^| sed -n "/^Capacity=/,/^DataWidth="%ram_data_width%"/p" ^| find "Capacity=" ^| sed "s/\s*$//g" ^| wc -l') do (set ram_modules_installed=%%x) goto :find_ram_module_speed :find_ram_module_speed for /f "tokens=*" %%x in ('wmic memorychip get /value ^| find "Speed=" ^| sed "s/\s*$//g" ^| uniq ^| head -n 1 ^| cut -d "=" -f 2') do (set ram_module_speed=%%x) for /f "tokens=*" %%x in ("%ram_module_speed% MHz") do (set ram_module_speed_pretty=%%x) goto :hardwarefull_totals :ram_virtual set ram_modules_installed=Virtual set ram_module_speed_pretty=Virtual goto :hardwarefull_totals :hardwarefull_totals for /f "tokens=*" %%x in ("RAM: Total installed: %ram_total_pretty%, Modules installed: %ram_modules_installed%, Module speed: %ram_module_speed_pretty%") do (set ram_value=%%x) echo %cpu_value% echo %ram_value% goto :exit :hardwarefull_virtual for /f "tokens=*" %%x in ("Virtual") do (set value=%%x) echo %value% goto :exit REM ######################### REM This displays the chassis. REM ######################### :chassis for /f "tokens=*" %%x in ('wmic csproduct get Vendor /value ^| find "Vendor=" ^| sed "s/\s*$//g" ^| cut -d "=" -f 2-') do (set manufacturer=%%x) echo %manufacturer% | grep -Ei "(Microsoft|VMware)" > nul 2>&1 if %errorlevel% equ 0 goto :hardwarefull_virtual for /f "tokens=*" %%x in ("%manufacturer%") do (set value=%%x) echo %value% goto :exit REM ######################### REM This displays the model. REM ######################### :model for /f "tokens=*" %%x in ('wmic csproduct get Vendor /value ^| find "Vendor=" ^| sed "s/\s*$//g" ^| cut -d "=" -f 2-') do (set manufacturer=%%x) echo %manufacturer% | grep -Ei "(Microsoft|VMware)" > nul 2>&1 if %errorlevel% equ 0 goto :hardwarefull_virtual for /f "tokens=*" %%x in ('wmic csproduct get Name /value ^| find "Name=" ^| sed "s/\s*$//g" ^| cut -d "=" -f 2-') do (set product_name=%%x) for /f "tokens=*" %%x in ('wmic csproduct get Version /value ^| find "Version=" ^| sed "s/\s*$//g" ^| cut -d "=" -f 2-') do (set version=%%x) for /f "tokens=*" %%x in ("%product_name% %version%") do (set value=%%x) echo %value% goto :exit REM ######################### REM This is where the script ends. REM ######################### :exit