OS Name Variable

前端 未结 2 1370
清歌不尽
清歌不尽 2021-01-23 07:21

I would like to run a script where I can get the windows Name and version of the system of all computers running in the company, put it in a text fil. Then make a system variabl

2条回答
  •  情话喂你
    2021-01-23 07:45

    Not exactly sure what you're looking for, but the biggest problem I see is that systeminfo takes forever to run and returns much more information than you're looking for. You'd be better off capturing wmi queries using wmic. This is basically a rewrite of your example script, just using wmic rather than systeminfo. It should be much, much faster.

    @echo off
    setlocal
    set prefix=G:\Directory
    
    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"
    
    >>"%prefix%\%COMPUTERNAME%" echo OS Name: %name%
    >>"%prefix%\%COMPUTERNAME%" echo OS Version: %version%
    >>"%prefix%\%COMPUTERNAME%" echo PC Model: %model%
    >>"%prefix%\%COMPUTERNAME%" echo BIOS Version: %bios%
    
    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
    

    Type wmic /? for more info, and try wmic computersystem get /? or similar to see a list of items that can be queried under each class.


    wmic is the Swiss Army knife of Windows. Fun fact: you can even use wmic to generate a web page table of installed software on a remote system.

提交回复
热议问题