Running the MOF Compiler on a File
You have two choices when compiling a MOF file: using the command-line utility or using a programmatic interface.
Until you run the MOF compiler, Mofcomp.exe, a provider is not registered with WMI and the classes it created in the MOF file are not available in the WMI repository. The following procedure describes how to compile a MOF file.
To run the MOF compiler on a file from the command line
- Call the MOF compiler from the command line, using the following syntax.
The MOF compiler supports a variety of switches to control special processing situations. All of the switches are optional, and any combination of switches is allowed. However, it does not make sense to use some of the switches in combination with others. For example, to combine the -class:updateonly and -class:createonly switches results in the compiler not performing any action.
By default, Mofcomp.exe stores the compiled classes in the root\default WMI namespace. Note that the default namespace for Mofcomp.exe is not the same as the default namespace for scripting. The default namespace for scripting is specified in the WMI Control on the Advanced tab. For more information, see Setting Namespace Security with the WMI Control.
You can change the namespace that receives the classes in two ways.
- Use the -N switch for the mofcomp command.
- Insert the preprocessor command #pragma namespace in the MOF file.
- Optionally, you can compile a MOF file programmatically. For more information, see IMofCompiler.
Build date: 10/15/2013