Some examples of retrieving data from WMI through TWAPI COM support. See Handling WMI events using TWAPI for examples related to setting up and trapping WMI events.
Note that these examples are for illustrative purposes. Where possible, it is much more efficient to use TWAPI's commands that directly layer on top of the Win32 API instead of going through the COM/WMI layers.
All examples assume you have initialized with
package require twapi 1.0 ;# Note you need the 1.0 release set wmi [twapi::_wmi]
and remember to do a
$wmi -destroy
at the end
Installed Applications
Show applications that are installed on the system (warning: may take a while to run)
$wmi -with { {ExecQuery "select * from Win32_Product"} } -iterate app { puts "[$app Name] [$app Version]" }
Show installed Microsoft applications (warning: may take a while to run)
$wmi -with { {ExecQuery "select * from Win32_Product where Vendor='Microsoft Corporation'"} } -iterate app { puts "[$app Name] [$app Version]" }
Show installed OS hotfixes
$wmi -with { {ExecQuery "select * from Win32_QuickFixEngineering"} } -iterate app { puts "[$app HotFixID] [$app Description] installed by [$app InstalledBy]" }
BIOS
Print BIOS information
$wmi -with { {ExecQuery "select * from Win32_BIOS"} } -iterate bios { puts [$bios GetObjectText_] }
Print a specific BIOS field
$wmi -with { {ExecQuery "select * from Win32_BIOS"} } -iterate bios { puts [$bios BiosVersion] }
Windows services
Print list of Windows services that are set to autostart.
$wmi -with { {ExecQuery "select * from Win32_Service where StartMode='Auto'"} } -iterate svc { puts [$svc DisplayName] }
Network adapters
Print list of network adapters in the system.
$wmi -with { {ExecQuery "select * from Win32_NetworkAdapter"} } -iterate net { puts "[$net DeviceID]:[$net Description]:[$net NetConnectionStatus]" }
Motherboard
Print motherboard manufacturer
$wmi -with { {ExecQuery "select * from Win32_BaseBoard"} } -iterate mb { puts "[$mb Manufacturer] [$mb Model] [$mb Name] SN# [$mb SerialNumber]" }