public class WMI4Java extends Object
Ex:
WMI4Java.get().computerName(".").namespace("root/cimv2").getWMIObject("Win32_BaseBoard");
The default computername will be . and the default namespace root/cimv2
All method will return an unchecked exception of type WMIException that can
be optionally handled (thanks to guilhermeoc97 for proposing an exception mechanism).
It supports two implementations:
-One based on PowerShell console (see project jPowerShell)
-The other based on a VB script (many thanks to Scriptomatic tool!)
But default it will use PowerShell but we can force an specific engine easily.
| Modifier and Type | Method and Description |
|---|---|
WMI4Java |
computerName(String computerName)
Set an specific computer name
By default it uses . |
WMI4Java |
filters(List<String> filters)
Sets the list of used filters when performing WMI query.
|
static WMI4Java |
get()
Static creation of instance
|
String |
getRawWMIObjectOutput(String wmiClass)
Query all the raw object data for an specific class
|
String |
getRawWMIObjectOutput(WMIClass wmiClass)
Query all the raw object data for an specific class
|
Map<String,String> |
getWMIObject(String wmiClass)
Query all the object data for an specific class
WARNINGN Notice that this method return a flat object. |
Map<String,String> |
getWMIObject(WMIClass wmiClass)
Query all the object data for an specific class
WARNINGN Notice that this method return a flat object. |
List<Map<String,String>> |
getWMIObjectList(String wmiClass)
Query a list of object data for an specific class
This method should be used to retrieve a list of objects instead of a flat key/value object. |
List<Map<String,String>> |
getWMIObjectList(WMIClass wmiClass)
Query a list of object data for an specific class
This method should be used to retrieve a list of objects instead of a flat key/value object. |
List<String> |
listClasses()
Query and list the WMI classes
|
List<String> |
listProperties(String wmiClass)
Query a WMI class and return all the available properties
|
WMI4Java |
namespace(String namespace)
Set an specific namespace
By default it uses root/cimv2 namespace |
WMI4Java |
PowerShellEngine()
Forces the use of PowerShell engine in order to query WMI
|
WMI4Java |
properties(List<String> properties)
Sets the list of required object properties.
|
WMI4Java |
VBSEngine()
Forces the use of VBS engine in order to query WMI
|
public static WMI4Java get()
public WMI4Java namespace(String namespace)
namespace - used namespace. Ex "root/WMI"public WMI4Java computerName(String computerName)
computerName - public WMI4Java PowerShellEngine()
public WMI4Java VBSEngine()
public WMI4Java properties(List<String> properties)
properties - list with the name of the properties we want to extractpublic WMI4Java filters(List<String> filters)
filters - list with the different filters to applypublic List<String> listClasses() throws WMIException
WMIExceptionpublic List<String> listProperties(String wmiClass) throws WMIException
wmiClass - the WMI class to queryWMIExceptionpublic Map<String,String> getWMIObject(WMIClass wmiClass)
In order to retrieve a list of objects, use instead
getWMIObjectList(WMIClass)
wmiClass - Enum that contains the most used classes (root/cimv2)public Map<String,String> getWMIObject(String wmiClass) throws WMIException
In order to retrieve a list of objects, use instead
getWMIObjectList(String)
wmiClass - Enum that contains the most used classes (root/cimv2)WMIExceptionpublic List<Map<String,String>> getWMIObjectList(WMIClass wmiClass)
wmiClass - Enum that contains the most used classes (root/cimv2)public List<Map<String,String>> getWMIObjectList(String wmiClass) throws WMIException
wmiClass - Enum that contains the most used classes (root/cimv2)WMIExceptionpublic String getRawWMIObjectOutput(WMIClass wmiClass)
wmiClass - Enum that contains the most used classes (root/cimv2)public String getRawWMIObjectOutput(String wmiClass) throws WMIException
wmiClass - string with the name of the class to queryWMIExceptionCopyright © 2018. All rights reserved.