質問

Hi I have a script that gets system information and stores the information as a system variable and parses detailed info into a flat text file in a folder. This information also lets me know who in the company has what type of windows, what type of computer, and the specs. The only thing I am missing is basically getting total physical RAM from the machine, making that total physical RAM as a System variable and getting detailed RAM info such as how many banks are populated and with how much RAM into the flat text file. Here is my script, any help would be greatly appreciated.

    @if %DEBUG%!==! echo on  
    setlocal
    set prefix=%city%\%location%\ComputerList\

    for /f "usebackq tokens=1,2 delims==|" %%I in (`wmic os get name^,version /format:list`) do 2>NUL set "%%I=%%J"
    for /f "tokens=2 delims==" %%I in ('wmic bios get version /format:list') do set "bios=%%I"
    for /f "tokens=2 delims==" %%I in ('wmic computersystem get model /format:list') do set "model=%%I"
    ::for /f "tokens=2 delims==" %%I in (systeminfo |find "Total Physical Memory" /format:list) do set "memory=%%I"

    >>"%prefix%\%COMPUTERNAME%.txt" echo OS Name: %name%
    >>"%prefix%\%COMPUTERNAME%txt" echo OS Version: %version%
    >>"%prefix%\%COMPUTERNAME%txt" echo PC Model: %model%
    >>"%prefix%\%COMPUTERNAME%txt" echo BIOS Version: %bios%
    ::>>"%prefix%\%COMPUTERNAME%txt" echo wmic MEMORYCHIP get banklabel, capacity, caption, devicelocator, partnumber

    if defined PROGRAMFILES(x86) (set arch=X64) else set arch=X86

    if "%name%" neq "%name:Windows 8=%" (
set out=%prefix%\Win8Comps.txt
    ) else if "%name%" neq "%name:Windows 7=%" (
set out=%prefix%\Win7Comps.txt
    ) else if "%name%" neq "%name:Windows Vista=%" (
set out=%prefix%\WinVistaComps.txt
    ) else if "%name%" neq "%name:Windows XP=%" (
set out=%prefix%\WinXPComps.txt
    )

    >>"%out%" echo %COMPUTERNAME% is running %name% in %arch% environment

    :SETX
    if exist "%windir%\System32\Setx.exe" (goto Language) else (
xcopy %city%\%location%\Setx.exe %Windir%\System32\Setx.exe
    )

    :Install_Language
    reg query "hklm\system\controlset001\control\nls\language" /v Installlanguage | FIND "0409" > nul && Set Install_Lang=English
    reg query "hklm\system\controlset001\control\nls\language" /v Installlanguage | FIND "040c" > nul && Set Install_Lang=French_Standard
    reg query "hklm\system\controlset001\control\nls\language" /v Installlanguage | FIND "0C0C" > nul && Set Install_Lang=French_Canadian


    :Locale_Language
    reg query "hklm\system\controlset001\control\nls\language" /ve | FIND "0409" > nul && Set Locale_Lang=English
    reg query "hklm\system\controlset001\control\nls\language" /ve | FIND "0c0c" > nul && Set Locale_Lang=French_Standard

    :Set_Sys_Variables
    Setx -m OS_Name "%name%"
    Setx -m Architechture %arch%
    Setx -m OS_Version %version%
    Setx -m PC_Model %model%
    Setx -m Bios_Ver "%bios%"
    Setx -m Install_Lang %Install_Lang%
    Setx -m Locale_Lang %Locale_Lang%
    Setx -m Memory %memory%
役に立ちましたか?

解決

@ECHO OFF
SETLOCAL
for /f "tokens=3*" %%I in ('systeminfo 2^>nul^|find "Total Physical Memory"') do set "memory=%%J"
ECHO from systeminfo: %memory%
for /f "delims=" %%I in ('wmic memphysical^|find "Physical"') do set "memory=%%I"
FOR %%I IN (%memory:~139%) DO SET memory=%%I&GOTO reportmem
:reportmem
ECHO from WMIC:%memory%
GOTO :EOF

Run report:

from systeminfo: 7,678 MB
from WMIC:8388608

So much for consistency - and I'm using . as a decimal point, , as a thousands-separator...

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top