Skip navigation

JSI Tip 8736. Windows XP and Windows Server 2003 contain the WMI (Windows Management Instrumentation) Wmic.exe command-line utility.

The Wmic.exe command-line utility gathers information from WMI for the local administrator.

NOTE: The first time that you run the Wmic.exe utility, it compiles its' .MOF file.

NOTE: See Windows Management Instrumentation

Sample Usage

To display the local computer name, O/S version, and Service Pack if Windows XP SP2 or greater is installed:
@echo off
setlocal
for /f %%v in ('wmic os get version /value^|find "Version"') do set %%v
if "%Version:~0,4%" NEQ "5.1." goto finish
for /f %%v in ('wmic os get servicepackmajorversion /value^|find "ServicePackMajorVersion"') do set %%v
if "%ServicePackMajorVersion%" LSS "2" goto finish
@echo %computername% %Version% %ServicePackMajorVersion%
:finish
endlocal
On my Windows XP SP2 desktop, the above script displays:

JSI009 5.1.2600 2



Hide comments

Comments

  • Allowed HTML tags: <em> <strong> <blockquote> <br> <p>

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.
Publish