我正在尝试获取我的安装程序脚本的系统信息。这是我的简单批处理脚本。
@echo off
setlocal enableextensions enabledelayedexpansion
echo System information now loading...
for /f "delims=" %%l in ('wmic os get * /format:list') do >nul 2>&1 set "OS_%%l"
for /f "delims=" %%l in ('wmic cpu get * /format:list') do >nul 2>&1 set "CPU_%%l"
set /a FreeSpace=0
for /f "skip=1 tokens=1,2" %%A in ('wmic logicaldisk get FreeSpace') do (
if "%%B" neq "" for /f %%N in ('powershell !FreeSpace!+%%A') do (
set FreeSpace=%%N
)
)
echo wsh.echo cdbl(%FreeSpace%)/1024/1024/1024 > %temp%.\tmp.vbs
for /f %%a in ('cscript //nologo %temp%.\tmp.vbs') do set /a HDD_FreeSpace=%%a
del %temp%.\tmp.vbs
set /a RAM_Memory=%OS_TotalVisibleMemorySize%/1024
set /a CPU_Speed=%CPU_NumberOfLogicalProcessors%*%CPU_CurrentClockSpeed%
>>SystemInfo.log 2>&1 echo Operating System: %OS_Caption%%OS_OSArchitecture% (%OS_Version%, Build %OS_BuildNumber%)
>>SystemInfo.log 2>&1 echo Processor: %CPU_Name%
>>SystemInfo.log 2>&1 echo RAM: %RAM_Memory% MB
>>SystemInfo.log 2>&1 echo HDD Total Free Space: %HDD_FreeSpace% GB
>>SystemSource.log 2>&1 echo %OS_Version%
>>SystemSource.log 2>&1 echo %CPU_Speed%
>>SystemSource.log 2>&1 echo %OS_TotalVisibleMemorySize%
>>SystemSource.log 2>&1 echo %FreeSpace%
exit
输出 SystemInfo.log
Operating System: Microsoft Windows 7 Professional 32-bit (6.1.7601, Build 7601)
Processor: Intel(R) Core(TM)2 CPU 6600 @ 2.40GHz
RAM: 3069 MB
HDD Total Free Space: 61 GB
输出 SystemSource.log
6.1.7601
4784
3143284
66427858944
一切似乎都很好。但是批处理脚本显示“缺少操作员”,我不知道为什么显示了一条消息,但所有输出都是正确的。
会不会崩溃?