|
WbemDump
The WbemDump sample
application allows the user to dump the contents of the CIMOM database to the
console or a file.
Building the WbemDump Application
The WbemDump sample can
be built from the command line using NMAKE, or it can be built using Microsoft
Visual C++.
From the command line
in the sample installation directory, type the following:
NMAKE /f “Makefile”
From Microsoft Visual
C++:
1. Select File + Open Workspace
2. Select the WbemDump.DSW file
NOTE: The WbemDump sample
depends on some of the functions defined in the UtilLib library sample. Both the NMAKE and Microsoft Visual C++
project files have been designed to build the UtilLib sample automatically, if
necessary, when building the WbemDump sample.
Using the WbemDump Application
The WbemDump is invoked at the command line prompt in the sample
installation directory using the following syntax:
wbemdump [switches] [Namespace [Class|ObjectPath] ]
wbemdump /Q [switches] Namespace QueryLanguage
Query
Where:
·
'Namespace' is the
namespace to dump (defaults to root\default)
·
'Class' is the name
of a specific class to dump (defaults to none)
·
'ObjectPath' is one
instance (e.g., "SClassA.KeyProp=\"foobar\"")
·
'QueryLanguage' is
any WBEM supported query language (currently only "WQL" is
supported).
·
'Query' is a valid
query for the specified language, enclosed in quotes
·
'switches' is one of:
o
/A:<Authority> Domain authority to connect with (e.g.,
NTLMDOMAIN:MYDOMAIN) for authentication
o
/B:<num> CreateEnum flags (SemiSync=16;
Forward=32)
o
/C:<file> Command file containing multiple
WBEMDUMP command lines
o
/D Don't show properties
o
/E Show system classes and
properties
o
/E1 Like /E except don't show
__SERVER or __PATH property
o
/E2 Shows command lines for
dumping instances (test mode)
o
/S Recurse down the tree
o
/S2 Recurse down Namespaces
(implies /S)
o
/G Do a GetObject on all
enumerated instances
o
/H:<name>:<value>
Specify context object value (test mode)
o
/I:<ImpLevel> Anonymous=1 Identify=2
Impersonate=3(default) Delegate=4
o
/M Get Class MOFS instead
of data values
o
/M2 Get Instance MOFS instead
of data values
o
/M3 Produce instance template
o
/O:<file> File name for output (creates
Unicode file)
o
/P:<Password> Password to connect with (default: NULL)
o
/T Print times on /Q
queries
o
/U:<UserID> UserID to connect with (default:
NULL)
o
/W Prompt
to continue on warning errors
o
/WY Print warnings and
continue
Usage Notes
1. You can redirect the output to a file using standard
redirection.
2. If the /C switch is used, the namespace on the
command line must be the same namespace that is used for each of the command
lines. It is not possible to use
different namespaces on the different lines in the command file.
Usage Examples
Command Line |
Result |
WBEMDUMP /S /E root\default |
Dumps everthing in root\default |
WBEMDUMP /S /E /M /M2 root\default |
Dump all class and instance MOFs |
WBEMDUMP root\default foo |
Dumps all instances of the foo class |
WBEMDUMP root\default foo.name=\"bar\" |
Dumps one instance of the foo class |
WBEMDUMP /S2 /M root |
Dumps MOFs for all non-system classes in all namespaces |
WBEMDUMP /Q root\default WQL "SELECT * FROM Environment WHERE
Name=\"Path\"" |
Dump all properties on all instances where the Name property has the
value “Path” |
A sample response file (test.cmd) for the /C switch for this command
line:
WBEMDUMP root\cimv2 /c:test.cmd
might look like this:
/m
Win32_SystemOperatingSystem
/m2
Win32_SystemOperatingSystem
/q wql "select *
from win32_bios"
General Notes
Things
to remember when you're building your own WMI client application:
1.
If you want your client to run
on NT and non-DCOM versions of Windows 95, manually load the ole32.dll and see
if CoInitializeSecurity() exists. This routine won’t exist on Windows 95
installations that don’t have DCOM installed separately. If this routine
doesn't exist, the asynchronous routines in this sample won’t work because of
mismatched security level problems. The synchronous techniques will still work.
2.
If you don’t care about
non-DCOM versions of Windows 95, you can define _WIN32_DCOM so that CoInitializeSecurity() is available for
implicit linking. Don't use _WIN32_WINNT to get this prototype since it won't
compile under the Windows 95/98 operating systems.
3.
In any case, the
CoInitializeSecurity() call (in InitInstance()) is required to work around a
security problem when WMI trying to call a Sink object but won't identify
itself. The CoInitializeSecurity() call turns off the authentication
requirement.
4.
WMI interfaces are defined
in wbemcli.h and wbemprov.h found in the wbem\include directory. You may #include both these files by
including just wbemidl.h located in the same directory.
5.
WMI interface CLSIDs are
defined in wbemuuid.lib. If you get unresolved externals in interfaces and
CLSIDs, this is what is missing.
6.
You'll need to link with
oleaut32.lib and ole32.lib to get the needed COM support.
7.
In the Link|Output
settings, specify 'wWinMainCRTStartup' as the entry point. This is per the
Unicode programming instructions.
8.
If you're using the makefiles, don't forget to set the Visual C++
environment variables. This is done by running VCVARS32.BAT.