This is the example, a shortcut was installed to this code
:
@echo off
::@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
:: $Header: C:/DBAREIS/Projects.PVCS/Win32/ScriptingTipsAndTricks/EXAMPLE[cmd].WMIC.exe [WMI From Windows Command Line (batch files)].cmd.pvcs 1.0 29 Jun 2014 12:51:22 USER "Dennis" $
::@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
::###########################################################################
::### Note WMIC.exe output is UNICODE but Windows batch needs it in ASCII ###
::###########################################################################
@setlocal ENABLEEXTENSIONS ENABLEDELAYEDEXPANSION
cls
::--- Run the wmic.exe command -----------------------------------------------
set TmpWmicResults=%TEMP%\wmic-UNICODE_Windows-needs-ASCII.txt
set WmicResults=%TEMP%\wmic.txt
set CMD=wmic.exe /FAILFAST:ON ComputerSystem GET Domain,Name,Model,UserName,SystemType,Manufacturer /value
echo C:\^> %CMD%
%CMD% > "%TmpWmicResults%" 2>&1
type "%TmpWmicResults%" > "%WmicResults%" 2>&1
type "%WmicResults%"
echo ----[ end of file "%WmicResults%" ] ----
::--- Process the WMI results ------------------------------------------------
echo.&echo.
for /F "usebackq delims=" %%l in ("%WmicResults%") do call :ProcessWmicExeLine "%%l"
::--- Display as "Latitude E6320 (Dell Inc. X86-based PC)" ------------------
echo EXTRACTED INFO: %WMIC_MODEL% (%WMIC_Manufacturer% %WMIC_SystemType%)
goto :EOF
::============================================================================
:ProcessWmicExeLine
::============================================================================
::--- Process the line if its not empty ----------------------------------
if "%~1" == "" goto :EOF
set WNAME=
set WKEY=
for /F "tokens=1,2 delims==" %%A in ("%~1") do set WNAME=%%A& set WKEY=%%B
if "%WKEY%" == "" goto :EOF
set WMIC_%WNAME%=%WKEY%
goto :EOF
::###########################################################################
::### Note WMIC.exe output is UNICODE but Windows batch needs it in ASCII ###
::###########################################################################
;--- Getting Help --------------------
Switches (/FAILFAST:ON): http://technet.microsoft.com/en-us/library/cc787035(v=ws.10).aspx
C:\> wmic /?
C:\> wmic logicaldisk /?
C:\> wmic logicaldisk GET /?
C:\> wmic CsProduct list full
;---Query local disk info (http://en.code-bude.net/2013/02/23/show-all-drives-in-command-prompt/) -------------
C:\> wmic logicaldisk get name, Description
Description Name
Local Fixed Disk C:
CD-ROM Disc D:
C:\> wmic logicaldisk get name, Description /VALUE
Description=Local Fixed Disk
Name=C:
Description=CD-ROM Disc
Name=D:
C:\> wmic logicaldisk where DriveType=3 GET Name /VALUE
Name=C:
C:\> wmic CsProduct GET Vendor,Name,Version,IdentifyingNumber /VALUE
C:\> wmic ComputerSystem GET Domain,Name,Model,UserName,SystemType,Manufacturer /value
;---------------------------------------------------------------------
;--- Get Remote Computer Details -------------------------------------
;---------------------------------------------------------------------
C:\> WMIC /NODE: 13.216.210.121 COMPUTERSYSTEM GET NAME /VALUE
Name=SOMESERVERNAME