Rob van der Woude's Scripting Pages
Powered by GeSHi

Source code for listwmiclasses.bat

(view source code of listwmiclasses.bat as plain text)

  1. @ECHO OFF
  2. IF NOT "%OS%"=="Windows_NT" GOTO Syntax
  3. IF NOT  "%~1"==""           GOTO Syntax
  4. WMIC  /?  > NUL 2>&1   ||   GOTO Syntax
  5.  
  6. SETLOCAL
  7. :: Clear existing values
  8. FOR %%A IN (CIM MSFT WIN32) DO (
  9. 	FOR /F "delims==" %%B IN ('SET %%A_ 2^>NUL') DO (
  10. 		SET %%B=
  11. 	)
  12. )
  13. :: Collect information on most of the available WMI classes; by using
  14. :: environment variables the data is sorted and deduplicated automatically
  15. FOR /F %%A IN ('WMIC /? ^| FINDSTR /R /B /C:"[A-Z][A-Z][A-Z ][A-Z ][A-Z ][A-Z ][A-Z ][A-Z ][A-Z ][A-Z ][A-Z ][A-Z ]" ^| FINDSTR /R /B /V /C:"For more information"') DO (
  16. 	FOR /F "tokens=4" %%B IN ('WMIC ALIAS %%A Get Target /Value 2^>NUL ^| FIND "="') DO (
  17. 		SET %%B=%%B
  18. 	)
  19. )
  20. :: List the results
  21. FOR %%A IN (CIM MSFT WIN32) DO (
  22. 	FOR /F "delims==" %%B IN ('SET %%A_') DO (
  23. 		ECHO.%%B
  24. 	)
  25. )
  26. ENDLOCAL
  27. GOTO:EOF
  28.  
  29.  
  30. :Syntax
  31. ECHO.
  32. ECHO ListWMIClasses.bat,  Version 1.01 for Windows XP and later
  33. ECHO List (a tiny fraction of) all WMI classes in the "root\CIMV2" namespace
  34. ECHO.
  35. ECHO Usage:    LISTWMICLASSES
  36. ECHO.
  37. ECHO Returns:  a sorted list of WMI classes, displayed on screen
  38. ECHO.
  39. ECHO Note:     Uses WMIC to list all "Target" classes of available Aliases.
  40. ECHO           So WMI classes without alias will not be included in the list.
  41. ECHO.
  42. ECHO Written by Rob van der Woude
  43. ECHO http://www.robvanderwoude.com
  44.  
  45. IF "%OS%"=="Windows_NT" EXIT /B 1
  46.  

page last modified: 2024-04-16; loaded in 0.0074 seconds