scripts-win/wmicsum/wmicsum.cmd
2021-11-26 22:01:09 +01:00

90 lines
No EOL
4.5 KiB
Batchfile
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

@echo off
SETLOCAL EnableDelayedExpansion
set ver=0.1beta
title WMIC Summary v%ver%
set cols=80
mode con cols=%cols% lines=40
color 0a
cls
echo Rcupration des informations matrielles...
REM skip saute 1 ligne, tokens=* rcupŠre toute la ligne, /v "^$" supprime les lignes vide
for /f "skip=1 tokens=*" %%A in ('%WINDIR%\System32\wbem\wmic.exe bios get serialnumber^| findstr /v "^$"') do set hard_sn1=%%A
for /f "skip=1 tokens=*" %%A in ('%WINDIR%\System32\wbem\wmic.exe baseboard get serialnumber^| findstr /v "^$"') do set hard_sn2=%%A
set hard_sn_both=0
if "%hard_sn1%" neq "" if "%hard_sn2%" neq "" set hard_sn_both=1
for /f "skip=1 tokens=*" %%A in ('%WINDIR%\System32\wbem\wmic.exe computersystem get model^| findstr /v "^$"') do set hard_model=%%A
for /f "skip=1 tokens=*" %%A in ('%WINDIR%\System32\wbem\wmic.exe computersystem get systemfamily^| findstr /v "^$"') do set hard_family=%%A
for /f "skip=1 tokens=*" %%A in ('%WINDIR%\System32\wbem\wmic.exe cpu get name ^| findstr /v "^$"') do set hard_cpu=%%A
for /f "skip=1 tokens=*" %%A in ('%WINDIR%\System32\wbem\wmic.exe computersystem get numberoflogicalprocessors ^| findstr /v "^$"') do set hard_cpunum=%%A
set hard_cpunum=%hard_cpunum: =%
for /f "skip=1 tokens=*" %%A in ('%WINDIR%\System32\wbem\wmic.exe os get totalvisiblememorysize ^| findstr /v "^$"') do set ram_total=%%A
set /a ram_total=%ram_total% / 1024
REM DISKDRIVE
set /a "hddnum=1"
for /f "skip=1 tokens=*" %%A in ('%WINDIR%\System32\wbem\wmic.exe diskdrive get caption ^| findstr /v "^$"') do (
set hdd!hddnum!name=%%A
set /a "hddnum+=1"
)
set /a "hddnum=1"
for /f "skip=1 tokens=*" %%A in ('%WINDIR%\System32\wbem\wmic.exe diskdrive get size ^| findstr /v "^$"') do (
set hdd!hddnum!size=%%A
set /a "hddnum+=1"
)
REM PRINTERS
for /f "skip=1 tokens=*" %%A in ('%WINDIR%\System32\wbem\wmic.exe printer where "default=True" get name^,portname ^| findstr /v "^$"') do set hard_print=%%A
echo %hard_print% (Par dfaut)> %temp%\wmicsum_printers.txt
for /f "skip=1 tokens=*" %%A in ('%WINDIR%\System32\wbem\wmic.exe printer where "default=False" get name^,portname ^| findstr /v "^$"') do (
set hard_print=%%A
echo !hard_print:~0,%cols%!>> %temp%\wmicsum_printers.txt
)
echo Rcupration des informations systŠme...
for /f "tokens=1 delims=|" %%A in ('%WINDIR%\System32\wbem\wmic.exe os get name ^| findstr Windows') do set os_name=%%A
for /f "skip=1 tokens=1 delims=|" %%A in ('%WINDIR%\System32\wbem\wmic.exe os get Version ^| findstr .') do set os_version=%%A
if "%CommonProgramW6432%"=="" (set os_arch=32 bits) else (set os_arch=64 bits)
for /f "skip=1 tokens=*" %%A in ('%WINDIR%\System32\wbem\wmic.exe computersystem get name ^| findstr /v "^$"') do set hostname=%%A
for /f "skip=1 tokens=*" %%A in ('%WINDIR%\System32\wbem\wmic.exe computersystem get domain ^| findstr /v "^$"') do set domain=%%A
cls
echo Matriel
echo îîîîîîîî
if %hard_sn_both%==1 echo Numro de srie (Bios) : %hard_sn1% && echo Numro de srie (Carte mŠre) : %hard_sn2%
if %hard_sn_both%==0 if "%hard_sn1%" neq "" echo Numro de srie : %hard_sn1%
if %hard_sn_both%==0 if "%hard_sn2%" neq "" echo Numro de srie : %hard_sn2%
echo ModŠle : %hard_model%
if "%hard_family%" neq "" echo Famille : %hard_family%
echo Processeur : %hard_cpu% (x%hard_cpunum%)
echo Mmoire vive totale : %ram_total% Mo
REM … l'tape d'avant une ligne fantome est gnre... je compense en diminuant de 1 la valeur de %hddnum%
set /a "hddnummax=hddnum-1"
set /a "hddnum=1"
:hddoutput
set name=!hdd%hddnum%name!
set size=!hdd%hddnum%size: =!
REM set /a size=%size% / ?1024
REM je ne peux pas utiliser set /a car le nombre que je divise est trop grand pour set ...
echo Disque %hddnum% : %name% %size:~0,-10% Go
if %hddnum% EQU %hddnummax% goto hddend
set /a "hddnum+=1"
goto hddoutput
:hddend
echo.
echo SystŠme
echo îîîîîîî
echo Version : %os_name% %os_version%%os_arch%
echo Hostname : %hostname%
echo Domaine : %domain%
echo.
echo # Disques logiques locaux
for /f "skip=1 tokens=*" %%A in ('wmic logicaldisk get VolumeName^,Name^,Description^ ^| findstr /v "^$" ^| findstr /v "rseau"') do echo %%A
echo.
echo # Disques rseaux
for /f "skip=1 tokens=*" %%A in ('wmic logicaldisk get ProviderName^,Name^,Description^ ^| findstr /v "^$" ^| findstr /v "Disque"') do echo %%A
echo.
echo # Imprimantes
type %temp%\wmicsum_printers.txt
pause > nul
REM suppression des fichiers temporaires avant fermeture
del /q %temp%\wmicsum_printers.txt